Skip to content

Instantly share code, notes, and snippets.

Avatar
:electron:
Always hacking

Remy Sharp remy

:electron:
Always hacking
View GitHub Profile
View _README.md
@remy
remy / fixed-point.js
Created Jul 20, 2021
The int16 is to keep the bytes in the data type and not slip into 32bit
View fixed-point.js
const scale = 8;
const d2f = (x) => Uint16Array.of(x * (1 << scale));
const f2d = (x) => Int16Array.of(x)[0] / (1 << scale);
const mul = (x, y) => Uint16Array.of(((x[0] >> 4) * (y[0] >> 2)) >> 2);
const a = d2f(-5); // ?
f2d(a) // ?
const b = d2f(0.8) // ?
f2d(b) // ?
View The Matrix Drinking Game.txt
~~~€[ The Matrix Drinking Game ]3~~~
Take One Drink When:
- Neo asks a question
- Someone says "The Matrix"
- They do a slow-motion, rotating scene
- Someone dodges bullets
- Morpheus says "real"
- A phone call is made
View index.js
const main = () => {
console.log("Hello World");
};
main();
View pal-demo.bas.txt
#autoline 10
RUN AT 3
LAYER 2,1: CLS
LOAD "pal-test.spr" BANK 13: ; spritesheet
LOAD "pal-test.map" BANK 14: ; tile map
LOAD "pal-test.pal" BANK 15: ; palette
TILE BANK 13: ; point tilemap to spritesheet
TILE DIM 14,0,16,16: ; using tile bank 14, offset 0, tile 16 wide, tile size 16
TILE 16,12: ; print tile for 16x12
@remy
remy / sfx.bas
Created Jul 20, 2020
Example of using OUT with AY chips in NextBASIC - main setup code by Dave Clarke
View sfx.bas
#autoline 10
RUN AT 3
PROC sfxsetup()
%i=0
DIM S$(4,20)
S$(1)="cccBccccCB"
S$(2)="baBA"
S$(3)="aAaAbBbBbB"
View _README.md

Assuming you're using VS Code to generate the NextBASIC files, you'll need:

  • bank-demo.bas.txt: "Export to binary BAS"
  • b12.bas.txt: "Export to BANK"

bank-demo is expecting to find the file named "b12.bas" - but you can change it as you please, the name is purely asthetic.

I've use autoline just because I can't be bothered with line numbers, but the line numbers in b12.bas can be anything (from what I understand) between 1-9999 and can overlap with line numbers in other banked code or your main NextBASIC file.

@remy
remy / _README.md
Created Jun 1, 2020
See readme for usage
View _README.md

For use with: https://github.com/kounch/knloader

Written for the mac, though I'm sure it can be adjusted to work on linux and WSL.

Make sure to change SD_CARD and GAMES to the root of your SD Card and the games/rom folder on the card - this last variable GAMES is needed in the knloader.bdt database.

Then run as:

sh knloader-db-maker.sh > knloader.bdt
@remy
remy / keys.bas
Created Apr 11, 2020
keyboard press testing for NextBASIC
View keys.bas
10 ;
11 ; Keypress combination example
12 ; Note that I am using the bit shift to allow
13 ; the INVERSE command to work.
14 ; If you're testing for a single keypress, then use:
15 ; IF %(IN $FBFE & 0b0010)=0 THEN ...
16 ; See page 272 of NextBASIC manual for ports
17 ;
100 PRINT AT 0,0; INVERSE %( IN $fbfe >> 0 & 1 ^ 1);"q"
101 PRINT AT 0,1; INVERSE %( IN $fbfe >> 1 & 1 ^ 1);"w"
@remy
remy / README.md
Created Mar 28, 2020
A Karabiner-Elements key config to let me use the esc key with cspect.
View README.md

In breif, this config lets me use the escape key to bring up the ZX Spectrum Next menu when running under CSpect on the mac.

The escape key will send: F10, shift+1, F10.

Using any modifier key and escape will exit CSpect (sending a real esc key to CSpect).

This config is used with Karabiner-Elements