@@ -4,13 +4,55 @@ extern(C):
44
55struct MouseData {
66 short x; short y;
7- short scrollx; short scrolly;
7+ byte scrollx; byte scrolly;
88 bool left; bool middle; bool right;
99}
1010
1111const int WIDTH = 240 ;
1212const int HEIGHT = 136 ;
1313
14+ // These are pointers.
15+ const FRAMEBUFFER_PTR = cast (ubyte * )0 ;
16+ const TILES_PTR = cast (ubyte * )0x4000 ;
17+ const SPRITES_PTR = cast (ubyte * )0x6000 ;
18+ const MAP_PTR = cast (ubyte * )0x8000 ;
19+ const GAMEPADS_PTR = cast (ubyte * )0xFF80 ;
20+ const MOUSE_PTR = cast (ubyte * )0xFF84 ;
21+ const KEYBOARD_PTR = cast (ubyte * )0xFF88 ;
22+ const SFX_STATE_PTR = cast (ubyte * )0xFF8C ;
23+ const SOUND_REGISTERS_PTR = cast (ubyte * )0xFF9C ;
24+ const WAVEFORMS_PTR = cast (ubyte * )0xFFE4 ;
25+ const SFX_PTR = cast (ubyte * )0x100E4 ;
26+ const MUSIC_PATTERNS_PTR = cast (ubyte * )0x11164 ;
27+ const MUSIC_TRACKS_PTR = cast (ubyte * )0x13E64 ;
28+ const SOUND_STATE_PTR = cast (ubyte * )0x13FFC ;
29+ const STEREO_VOLUME_PTR = cast (ubyte * )0x14000 ;
30+ const PERSISTENT_MEMORY_PTR = cast (ubyte * )0x14004 ;
31+ const SPRITE_FLAGS_PTR = cast (ubyte * )0x14404 ;
32+ const SYSTEM_FONT_PTR = cast (ubyte * )0x14604 ;
33+ const WASM_FREE_RAM_PTR = cast (ubyte * )0x18000 ;
34+
35+ // These are bounded arrays.
36+ ubyte [] FRAMEBUFFER () { return (cast (ubyte * )0 )[0 .. 16319 ]; } // VRAM bank 0 screen area
37+ ubyte [] TILES () { return (cast (ubyte * )0x4000 )[0 .. 8191 ]; }
38+ ubyte [] SPRITES () { return (cast (ubyte * )0x4000 )[0 .. 8191 ]; }
39+ ubyte [] MAP () { return (cast (ubyte * )0x8000 )[0 .. 32639 ]; }
40+ ubyte [] GAMEPADS () { return (cast (ubyte * )0xFF80 )[0 .. 3 ]; }
41+ ubyte [] MOUSE () { return (cast (ubyte * )0xFF84 )[0 .. 3 ]; }
42+ ubyte [] KEYBOARD () { return (cast (ubyte * )0xFF88 )[0 .. 3 ]; }
43+ ubyte [] SFX_STATE () { return (cast (ubyte * )0xFF8C )[0 .. 15 ]; }
44+ ubyte [] SOUND_REGISTERS () { return (cast (ubyte * )0xFF9C )[0 .. 71 ]; }
45+ ubyte [] WAVEFORMS () { return (cast (ubyte * )0xFFE4 )[0 .. 255 ]; }
46+ ubyte [] SFX () { return (cast (ubyte * )0x100E4 )[0 .. 4223 ]; }
47+ ubyte [] MUSIC_PATTERNS () { return (cast (ubyte * )0x11164 )[0 .. 11519 ]; }
48+ ubyte [] MUSIC_TRACKS () { return (cast (ubyte * )0x13E64 )[0 .. 407 ]; }
49+ ubyte [] SOUND_STATE () { return (cast (ubyte * )0x13FFC )[0 .. 3 ]; }
50+ ubyte [] STEREO_VOLUME () { return (cast (ubyte * )0x14000 )[0 .. 3 ]; }
51+ ubyte [] PERSISTENT_MEMORY () { return (cast (ubyte * )0x14004 )[0 .. 1023 ]; }
52+ ubyte [] SPRITE_FLAGS () { return (cast (ubyte * )0x14404 )[0 .. 511 ]; }
53+ ubyte [] SYSTEM_FONT () { return (cast (ubyte * )0x14604 )[0 .. 2047 ]; }
54+ ubyte [] WASM_FREE_RAM () { return (cast (ubyte * )0x18000 )[0 .. 163839 ]; } // 160kb
55+
1456int btn (int id);
1557bool btnp (int id, int hold, int period);
1658void circ (int x, int y, int radius, int color);
@@ -25,7 +67,7 @@ int font(char* text, int x, int y, ubyte transcolors, int colorcount, int width,
2567bool fset (int id, ubyte flag, bool value);
2668bool key (int keycode);
2769bool keyp (int keycode, int hold, int period);
28- void line (int x0, int y0, int x1, int y1, int color);
70+ void line (float x0, float y0, float x1, float y1, byte color);
2971void map (int x, int y, int w, int h, int sx, int sy, ubyte transcolors, int colorcount, int scale, int remap);
3072void memcpy (uint copyto, uint copyfrom, uint length);
3173void memset (uint addr, ubyte value, uint length);
@@ -34,27 +76,27 @@ void mouse(MouseData* data);
3476void mset (int x, int y, bool value);
3577void music (int track, int frame, int row, bool loop, bool sustain, int tempo, int speed);
3678ubyte peek (int addr, int bits);
37- int print (const char * txt, int x, int y, int color, int fixed, int scale, int alt);
3879ubyte peek4 (uint addr4);
3980ubyte peek2 (uint addr2);
4081ubyte peek1 (uint bitaddr);
4182void pix (int x, int y, int color);
4283uint pmem (uint index, uint value);
43- void poke (uint addr, ubyte value, int bits);
44- void poke4 (uint addr4, ubyte value);
45- void poke2 (uint addr2, ubyte value);
46- void poke1 (uint bitaddr, ubyte value);
84+ void poke (int addr, byte value, byte bits);
85+ void poke4 (int addr4, byte value);
86+ void poke2 (int addr2, byte value);
87+ void poke1 (int bitaddr, byte value);
88+ int print (const char * txt, int x, int y, int color, int fixed, int scale, int alt);
4789void rect (int x, int y, int w, int h, int color);
4890void rectb (int x, int y, int w, int h, int color);
4991void reset ();
5092void sfx (int id, int note, int octave, int duration, int channel, int volumeLeft, int volumeRight, int speed);
5193void spr (int id, int x, int y, uint * transcolors, uint colorcount, int scale, int flip, int rotate, int w, int h);
5294void sync (int mask, int bank, bool tocart);
5395void trace (const char * txt, int color);
54- void textri (float x1, float y1, float x2, float y2, float x3, float y3, float u1, float v1, float u2, float v2, float u3, float v3, int texsrc, ubyte transcolors, int colorcount, float z1, float z2, float z3, bool persp);
96+ void ttri (float x1, float y1, float x2, float y2, float x3, float y3, float u1, float v1, float u2, float v2, float u3, float v3, int texsrc, ubyte transcolors, int colorcount, float z1, float z2, float z3, bool persp);
5597void tri (float x1, float y1, float x2, float y2, float x3, float y3, int color);
5698void trib (float x1, float y1, float x2, float y2, float x3, float y3, int color);
57- int time ();
99+ float time ();
58100int tstamp ();
59101int vbank (int bank);
60102
0 commit comments