romdevtools 0.71.0 → 0.84.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +19 -16
- package/CHANGELOG.md +196 -0
- package/README.md +5 -5
- package/examples/README.md +1 -0
- package/examples/gametank/templates/gt_draw.h +91 -0
- package/examples/gametank/templates/gt_hud.h +89 -0
- package/examples/gametank/templates/gt_palette.h +59 -0
- package/examples/gametank/templates/gt_sound.h +90 -0
- package/examples/gametank/templates/gt_sprites.h +53 -0
- package/examples/gametank/templates/platformer.c +318 -0
- package/examples/gametank/templates/puzzle.c +295 -0
- package/examples/gametank/templates/racing.c +139 -0
- package/examples/gametank/templates/shmup.c +277 -0
- package/examples/gametank/templates/sports.c +119 -0
- package/package.json +23 -22
- package/src/cores/capabilities.js +24 -0
- package/src/cores/registry.js +7 -1
- package/src/host/LibretroHost.js +90 -17
- package/src/host/callbacks.js +20 -2
- package/src/host/cpu-state.js +17 -0
- package/src/host/gametank-acp-state.js +53 -0
- package/src/http/skill-doc.js +10 -6
- package/src/mcp/tools/audio.js +1 -1
- package/src/mcp/tools/cart-parts.js +76 -0
- package/src/mcp/tools/lifecycle.js +1 -1
- package/src/mcp/tools/platform-tools.js +9 -1
- package/src/mcp/tools/platforms.js +46 -10
- package/src/mcp/tools/toolchain.js +35 -10
- package/src/platforms/gametank/lib/gt/audio/acp_image.bin +0 -0
- package/src/platforms/gametank/lib/gt/audio/audio_coprocessor.c +55 -0
- package/src/platforms/gametank/lib/gt/audio/audio_coprocessor.h +34 -0
- package/src/platforms/gametank/lib/gt/audio/audio_fw.asm +223 -0
- package/src/platforms/gametank/lib/gt/audio/audio_fw_blob.s +8 -0
- package/src/platforms/gametank/lib/gt/audio/instruments.c +79 -0
- package/src/platforms/gametank/lib/gt/audio/instruments.h +25 -0
- package/src/platforms/gametank/lib/gt/audio/music.c +370 -0
- package/src/platforms/gametank/lib/gt/audio/music.h +35 -0
- package/src/platforms/gametank/lib/gt/audio/note_numbers.h +132 -0
- package/src/platforms/gametank/lib/gt/audio/scaled_sines.raw +0 -0
- package/src/platforms/gametank/lib/gt/audio/sine_256_-63_63.bin +0 -0
- package/src/platforms/gametank/lib/gt/banking.c +29 -0
- package/src/platforms/gametank/lib/gt/banking.h +8 -0
- package/src/platforms/gametank/lib/gt/banking2.s +41 -0
- package/src/platforms/gametank/lib/gt/crt0.s +102 -0
- package/src/platforms/gametank/lib/gt/draw_logo.s +55 -0
- package/src/platforms/gametank/lib/gt/feature/persist/persist.c +103 -0
- package/src/platforms/gametank/lib/gt/feature/persist/persist.h +13 -0
- package/src/platforms/gametank/lib/gt/feature/random/random.c +40 -0
- package/src/platforms/gametank/lib/gt/feature/random/random.h +18 -0
- package/src/platforms/gametank/lib/gt/feature/text/text.c +111 -0
- package/src/platforms/gametank/lib/gt/feature/text/text.h +25 -0
- package/src/platforms/gametank/lib/gt/gametank.c +12 -0
- package/src/platforms/gametank/lib/gt/gametank.h +80 -0
- package/src/platforms/gametank/lib/gt/gametank_logo.inc +393 -0
- package/src/platforms/gametank/lib/gt/gen/assets/assets_index.h +9 -0
- package/src/platforms/gametank/lib/gt/gen/assets/sdk_default.h +5 -0
- package/src/platforms/gametank/lib/gt/gen/bank_nums.h +11 -0
- package/src/platforms/gametank/lib/gt/gen/modules_enabled.h +4 -0
- package/src/platforms/gametank/lib/gt/gen/modules_enabled.inc +4 -0
- package/src/platforms/gametank/lib/gt/gfx/draw_direct.c +132 -0
- package/src/platforms/gametank/lib/gt/gfx/draw_direct.h +75 -0
- package/src/platforms/gametank/lib/gt/gfx/draw_queue.c +177 -0
- package/src/platforms/gametank/lib/gt/gfx/draw_queue.h +35 -0
- package/src/platforms/gametank/lib/gt/gfx/draw_util.s +157 -0
- package/src/platforms/gametank/lib/gt/gfx/gfx_sys.c +43 -0
- package/src/platforms/gametank/lib/gt/gfx/gfx_sys.h +46 -0
- package/src/platforms/gametank/lib/gt/gfx/sprites.c +216 -0
- package/src/platforms/gametank/lib/gt/gfx/sprites.h +41 -0
- package/src/platforms/gametank/lib/gt/init.c +9 -0
- package/src/platforms/gametank/lib/gt/input.c +26 -0
- package/src/platforms/gametank/lib/gt/input.h +20 -0
- package/src/platforms/gametank/lib/gt/interrupt.s +67 -0
- package/src/platforms/gametank/lib/gt/vectors.s +14 -0
- package/src/platforms/gametank/lib/gt/wait.s +53 -0
- package/src/platforms/gba/MENTAL_MODEL.md +22 -1
- package/src/playtest/playtest.js +174 -26
- package/src/playtest/resampler/build.sh +19 -0
- package/src/playtest/resampler/index.mjs +75 -0
- package/src/playtest/resampler/resampler.c +129 -0
- package/src/playtest/resampler/resampler.mjs +2 -0
- package/src/playtest/resampler/resampler.wasm +0 -0
- package/src/toolchains/arm-none-eabi-gcc/gcc.js +39 -188
- package/src/toolchains/asar/asar.js +10 -15
- package/src/toolchains/cc65/cc65.js +82 -92
- package/src/toolchains/cc65/da65.js +12 -17
- package/src/toolchains/cc65/preset-resolver.js +13 -2
- package/src/toolchains/cc65/presets/gametank/gametank.h +80 -0
- package/src/toolchains/cc65/presets/gametank/sdk.cfg +32 -0
- package/src/toolchains/cc65/presets/gametank/sdk.crt0.s +61 -0
- package/src/toolchains/cc65/presets/gametank/sdk.vectors.s +11 -0
- package/src/toolchains/cc65/presets/gametank/single-bank.cfg +28 -0
- package/src/toolchains/cc65/presets/gametank/single-bank.crt0.s +71 -0
- package/src/toolchains/cc65/presets/gametank/single-bank.vectors.s +12 -0
- package/src/toolchains/common/c-build.js +109 -0
- package/src/toolchains/common/gcc-toolchain.js +164 -0
- package/src/toolchains/common/wasm-tool.js +101 -0
- package/src/toolchains/dasm/dasm.js +12 -18
- package/src/toolchains/gba-c/gba-c.js +253 -305
- package/src/toolchains/genesis-c/genesis-c.js +196 -225
- package/src/toolchains/index.js +58 -4
- package/src/toolchains/m68k-elf-gcc/gcc.js +39 -202
- package/src/toolchains/mips-c/mips-c.js +68 -78
- package/src/toolchains/mips-elf-gcc/gcc.js +55 -118
- package/src/toolchains/rgbds/rgbds.js +7 -19
- package/src/toolchains/sdcc/sdcc.js +35 -26
- package/src/toolchains/sh-c/sh-c.js +44 -52
- package/src/toolchains/sh-elf-gcc/gcc.js +55 -110
- package/src/toolchains/sjasm/sjasm.js +10 -14
- package/src/toolchains/snes-c/snes-c.js +125 -150
- package/src/toolchains/tcc816/tcc816.js +10 -15
- package/src/toolchains/vasm68k/vasm68k.js +11 -16
- package/src/toolchains/wladx/wladx.js +5 -17
- package/src/toolchains/z80/binutils.js +5 -11
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; crt0.s
|
|
3
|
+
; ---------------------------------------------------------------------------
|
|
4
|
+
;
|
|
5
|
+
; Startup code for cc65 (GameTank version)
|
|
6
|
+
|
|
7
|
+
.export _init, _exit
|
|
8
|
+
.import _main, _sdk_init
|
|
9
|
+
|
|
10
|
+
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
|
11
|
+
.import __RAM_START__, __RAM_SIZE__ ; Linker generated
|
|
12
|
+
|
|
13
|
+
.import copydata, zerobss, initlib, donelib
|
|
14
|
+
|
|
15
|
+
.import _romBankMirror
|
|
16
|
+
.import _bankflip
|
|
17
|
+
.import _bank_shift_out
|
|
18
|
+
|
|
19
|
+
.export _AudioFWPkg
|
|
20
|
+
|
|
21
|
+
.PC02
|
|
22
|
+
|
|
23
|
+
BankReg = $2005
|
|
24
|
+
VIA = $2800
|
|
25
|
+
ORB = 0
|
|
26
|
+
ORAr = 1
|
|
27
|
+
DDRB = 2
|
|
28
|
+
DDRA = 3
|
|
29
|
+
T1C = 5
|
|
30
|
+
ACR = $B
|
|
31
|
+
PCR = $C
|
|
32
|
+
IFR = $D
|
|
33
|
+
IER = $E
|
|
34
|
+
|
|
35
|
+
.include "zeropage.inc"
|
|
36
|
+
|
|
37
|
+
; ----------------------------------------------------------<.BANK (_sdk_init)----------------
|
|
38
|
+
; Place the startup code in a special segment
|
|
39
|
+
|
|
40
|
+
.segment "STARTUP"
|
|
41
|
+
|
|
42
|
+
; ---------------------------------------------------------------------------
|
|
43
|
+
; A little light 6502 housekeeping
|
|
44
|
+
|
|
45
|
+
_init: LDX #$FF ; Initialize stack pointer to $01FF
|
|
46
|
+
TXS
|
|
47
|
+
CLD ; Clear decimal mode
|
|
48
|
+
|
|
49
|
+
ldx #0
|
|
50
|
+
viaWakeup:
|
|
51
|
+
inx
|
|
52
|
+
bne viaWakeup
|
|
53
|
+
|
|
54
|
+
LDA #40
|
|
55
|
+
STA BankReg
|
|
56
|
+
STA $1FFF
|
|
57
|
+
STZ BankReg
|
|
58
|
+
STZ $1FFF
|
|
59
|
+
|
|
60
|
+
LDA #%00000111
|
|
61
|
+
STA VIA+DDRA
|
|
62
|
+
LDA #$FF
|
|
63
|
+
STA VIA+ORAr
|
|
64
|
+
LDA #$FD
|
|
65
|
+
jsr _bank_shift_out
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
; ---------------------------------------------------------------------------
|
|
69
|
+
; Set cc65 argument stack pointer
|
|
70
|
+
|
|
71
|
+
LDA #<(__RAM_START__ + __RAM_SIZE__)
|
|
72
|
+
STA c_sp
|
|
73
|
+
LDA #>(__RAM_START__ + __RAM_SIZE__)
|
|
74
|
+
STA c_sp+1
|
|
75
|
+
|
|
76
|
+
; ---------------------------------------------------------------------------
|
|
77
|
+
; Initialize memory storage
|
|
78
|
+
|
|
79
|
+
JSR zerobss ; Clear BSS segment
|
|
80
|
+
JSR copydata ; Initialize DATA segment
|
|
81
|
+
JSR initlib ; Run constructors
|
|
82
|
+
|
|
83
|
+
STZ _bankflip
|
|
84
|
+
|
|
85
|
+
; ---------------------------------------------------------------------------
|
|
86
|
+
; Call main()
|
|
87
|
+
|
|
88
|
+
LDA #$FD
|
|
89
|
+
jsr _bank_shift_out
|
|
90
|
+
|
|
91
|
+
JSR _sdk_init
|
|
92
|
+
JSR _main
|
|
93
|
+
|
|
94
|
+
; ---------------------------------------------------------------------------
|
|
95
|
+
; Back from main (this is also the _exit entry): force a software break
|
|
96
|
+
|
|
97
|
+
_exit: JSR donelib ; Run destructors
|
|
98
|
+
BRK
|
|
99
|
+
|
|
100
|
+
.segment "COMMON"
|
|
101
|
+
_AudioFWPkg:
|
|
102
|
+
.incbin "build/assets/audio_fw.bin.deflate"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
; ---------------------------------------------------------------------------
|
|
2
|
+
; draw_logo.s
|
|
3
|
+
; ---------------------------------------------------------------------------
|
|
4
|
+
;
|
|
5
|
+
; Draw the GameTank logo
|
|
6
|
+
|
|
7
|
+
.export _draw_gametank_logo
|
|
8
|
+
|
|
9
|
+
DMA_VX = $4000
|
|
10
|
+
DMA_VY = $4001
|
|
11
|
+
DMA_GX = $4002
|
|
12
|
+
DMA_GY = $4003
|
|
13
|
+
DMA_WIDTH = $4004
|
|
14
|
+
DMA_HEIGHT = $4005
|
|
15
|
+
DMA_Start = $4006
|
|
16
|
+
DMA_Color = $4007
|
|
17
|
+
|
|
18
|
+
.segment "LOADERS"
|
|
19
|
+
|
|
20
|
+
;includes labels LogoXVals and LogoWVals
|
|
21
|
+
.include "gametank_logo.inc"
|
|
22
|
+
|
|
23
|
+
.proc _draw_gametank_logo: near
|
|
24
|
+
PHY
|
|
25
|
+
LDY #1
|
|
26
|
+
STY DMA_HEIGHT
|
|
27
|
+
STA DMA_Color
|
|
28
|
+
LDX #0
|
|
29
|
+
LDY #56
|
|
30
|
+
DrawLoop:
|
|
31
|
+
LDA LogoWVals, x
|
|
32
|
+
DrawLoopSkipW:
|
|
33
|
+
BEQ NextLine
|
|
34
|
+
STA DMA_WIDTH
|
|
35
|
+
LDA LogoXVals, x
|
|
36
|
+
STA DMA_VX
|
|
37
|
+
LDA #1
|
|
38
|
+
STA DMA_Start
|
|
39
|
+
INX
|
|
40
|
+
BRA DrawLoop
|
|
41
|
+
NextLine:
|
|
42
|
+
INY
|
|
43
|
+
STY DMA_VY
|
|
44
|
+
INX
|
|
45
|
+
LDA LogoWVals, x
|
|
46
|
+
BEQ EndLoop
|
|
47
|
+
BRA DrawLoopSkipW
|
|
48
|
+
EndLoop:
|
|
49
|
+
|
|
50
|
+
SEI
|
|
51
|
+
CLI
|
|
52
|
+
PLY
|
|
53
|
+
RTS ; Return to caller
|
|
54
|
+
|
|
55
|
+
.endproc
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#include "banking.h"
|
|
2
|
+
#include "gametank.h"
|
|
3
|
+
#include "persist.h"
|
|
4
|
+
#include "bank_nums.h"
|
|
5
|
+
#include "modules_enabled.h"
|
|
6
|
+
|
|
7
|
+
#define MAGIC_SAVE_NUM 0x42
|
|
8
|
+
|
|
9
|
+
#pragma rodata-name (push, "SAVE")
|
|
10
|
+
const char save_canary = MAGIC_SAVE_NUM;
|
|
11
|
+
#pragma rodata-name (pop)
|
|
12
|
+
|
|
13
|
+
#ifdef ENABLE_MODULE_PERSIST
|
|
14
|
+
|
|
15
|
+
char executing_from_rom() {
|
|
16
|
+
asm("PLX");
|
|
17
|
+
asm("PLA");
|
|
18
|
+
asm("PHA");
|
|
19
|
+
asm("PHX");
|
|
20
|
+
return __A__ > 0xC0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#pragma code-name (push, "DATA")
|
|
24
|
+
#pragma optimize (push, on)
|
|
25
|
+
|
|
26
|
+
char i, k;
|
|
27
|
+
void clear_save_sector() {
|
|
28
|
+
if(executing_from_rom()) {
|
|
29
|
+
while(1) {}
|
|
30
|
+
}
|
|
31
|
+
*dma_flags = flagsMirror & ~(DMA_IRQ | DMA_NMI);
|
|
32
|
+
asm("SEI");
|
|
33
|
+
push_rom_bank();
|
|
34
|
+
change_rom_bank(BANK_SAVE);
|
|
35
|
+
//unlock
|
|
36
|
+
*((unsigned char*) 0x8AAA) = 0xAA;
|
|
37
|
+
*((unsigned char*) 0x8555) = 0x55;
|
|
38
|
+
//setup
|
|
39
|
+
*((unsigned char*) 0x8AAA) = 0x80;
|
|
40
|
+
|
|
41
|
+
//unlock
|
|
42
|
+
*((unsigned char*) 0x8AAA) = 0xAA;
|
|
43
|
+
*((unsigned char*) 0x8555) = 0x55;
|
|
44
|
+
|
|
45
|
+
//erase
|
|
46
|
+
*((unsigned char*) 0x8000) = 0x30;
|
|
47
|
+
|
|
48
|
+
i = *((unsigned char*) 0x8000);
|
|
49
|
+
k = *((unsigned char*) 0x8000);
|
|
50
|
+
while(i != k) {
|
|
51
|
+
i = k;
|
|
52
|
+
k = *((unsigned char*) 0x8000);
|
|
53
|
+
}
|
|
54
|
+
*dma_flags = flagsMirror;
|
|
55
|
+
asm("CLI");
|
|
56
|
+
pop_rom_bank();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
void unlock_bypass() {
|
|
60
|
+
*((unsigned char*) 0x8AAA) = 0xAA;
|
|
61
|
+
*((unsigned char*) 0x8555) = 0x55;
|
|
62
|
+
*((unsigned char*) 0x8AAA) = 0x20;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
void lock_bypass() {
|
|
66
|
+
*((unsigned char*) 0x8000) = 0x90;
|
|
67
|
+
*((unsigned char*) 0x8000) = 0x00;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//src assumed not Flash ROM
|
|
71
|
+
//dest assumned to be in Flash ROM
|
|
72
|
+
void save_write(void *src, void *dest, char len) {
|
|
73
|
+
if(executing_from_rom()) {
|
|
74
|
+
while(1) {}
|
|
75
|
+
}
|
|
76
|
+
*dma_flags = flagsMirror & ~(DMA_IRQ | DMA_NMI);
|
|
77
|
+
asm("SEI");
|
|
78
|
+
push_rom_bank();
|
|
79
|
+
change_rom_bank(BANK_SAVE);
|
|
80
|
+
i = 0;
|
|
81
|
+
k = len;
|
|
82
|
+
unlock_bypass();
|
|
83
|
+
while(k) {
|
|
84
|
+
*((unsigned char*) 0x8000) = 0xA0;
|
|
85
|
+
((char *)dest)[i] = ((char *)src)[i];
|
|
86
|
+
while(((char *) dest)[i] != ((char *) src)[i]) {
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
i++;
|
|
90
|
+
k--;
|
|
91
|
+
}
|
|
92
|
+
lock_bypass();
|
|
93
|
+
*dma_flags = flagsMirror;
|
|
94
|
+
asm("CLI");
|
|
95
|
+
pop_rom_bank();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
#pragma optimize (pop)
|
|
100
|
+
#pragma code-name (pop)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
#endif
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#ifndef PERSIST_H
|
|
2
|
+
#define PERSIST_H
|
|
3
|
+
|
|
4
|
+
#include "modules_enabled.h"
|
|
5
|
+
|
|
6
|
+
#ifndef ENABLE_MODULE_PERSIST
|
|
7
|
+
#error "Module PERSIST included but not enabled!"
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
void clear_save_sector();
|
|
11
|
+
void save_write(void *src, void *dest, char len);
|
|
12
|
+
|
|
13
|
+
#endif
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#include "random.h"
|
|
2
|
+
#include "modules_enabled.h"
|
|
3
|
+
|
|
4
|
+
#ifdef ENABLE_MODULE_RANDOM
|
|
5
|
+
|
|
6
|
+
int xorshift16(int x) {
|
|
7
|
+
x |= x == 0; /* if x == 0, set x = 1 instead */
|
|
8
|
+
x ^= (x & 0x07ff) << 5;
|
|
9
|
+
x ^= x >> 7;
|
|
10
|
+
x ^= (x & 0x0003) << 14;
|
|
11
|
+
return x;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
int rnd_seed = 234;
|
|
15
|
+
|
|
16
|
+
int rnd() {
|
|
17
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
18
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
19
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
20
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
21
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
22
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
23
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
24
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
25
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
26
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
27
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
28
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
29
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
30
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
31
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
32
|
+
rnd_seed = xorshift16(rnd_seed);
|
|
33
|
+
return rnd_seed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
int rnd_range(int low, int high) {
|
|
37
|
+
return ((rnd() & 0x7FFF) % (high - low)) + low;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#endif
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Provides random numbers
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#ifndef RANDOM_H
|
|
6
|
+
#define RANDOM_H
|
|
7
|
+
|
|
8
|
+
#include "modules_enabled.h"
|
|
9
|
+
|
|
10
|
+
#ifndef ENABLE_MODULE_RANDOM
|
|
11
|
+
#error "Module RANDOM included but not enabled!"
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
int rnd();
|
|
15
|
+
|
|
16
|
+
int rnd_range(int low, int high);
|
|
17
|
+
|
|
18
|
+
#endif
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
#include "text.h"
|
|
2
|
+
|
|
3
|
+
#include "gametank.h"
|
|
4
|
+
#include "banking.h"
|
|
5
|
+
#include "draw_direct.h"
|
|
6
|
+
#include "sdk_default.h"
|
|
7
|
+
#include "modules_enabled.h"
|
|
8
|
+
#include "bank_nums.h"
|
|
9
|
+
|
|
10
|
+
#define SPRITE_CHAR_W 8
|
|
11
|
+
#define SPRITE_CHAR_H 8
|
|
12
|
+
#define SPRITE_ROW_0_F 0x68
|
|
13
|
+
#define SPRITE_ROW_G_V 0x70
|
|
14
|
+
#define SPRITE_ROW_W_Z 0x78
|
|
15
|
+
#define SPRITE_CHAR_BLANK_X 0x70
|
|
16
|
+
#define SPRITE_CHAR_BLANK_Y 0x78
|
|
17
|
+
|
|
18
|
+
#define TEXT_CHAR_WIDTH 8
|
|
19
|
+
#define TEXT_CHAR_HEIGHT 8
|
|
20
|
+
#define TEXT_LINE_HEIGHT 8
|
|
21
|
+
|
|
22
|
+
#ifdef ENABLE_MODULE_TEXT
|
|
23
|
+
|
|
24
|
+
char font_slot;
|
|
25
|
+
char text_cursor_x, text_cursor_y;
|
|
26
|
+
char text_print_width, text_print_line_start;
|
|
27
|
+
unsigned char text_color;
|
|
28
|
+
char font_offset_x, font_offset_y;
|
|
29
|
+
|
|
30
|
+
void text_init() {
|
|
31
|
+
text_cursor_x = 0;
|
|
32
|
+
text_cursor_y = 0;
|
|
33
|
+
text_print_width = 128;
|
|
34
|
+
text_print_line_start = 0;
|
|
35
|
+
text_color = TEXT_COLOR_BLACK;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
SpriteSlot text_load_font() {
|
|
39
|
+
font_slot = allocate_sprite(&ASSET__sdk_default__bios8_bmp_load_list);
|
|
40
|
+
font_offset_x = SPRITE_OFFSET_X(font_slot);
|
|
41
|
+
font_offset_y = SPRITE_OFFSET_Y(font_slot);
|
|
42
|
+
return font_slot;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
char text_tmp;
|
|
46
|
+
void text_print_string(char* str) {
|
|
47
|
+
*dma_flags = (flagsMirror | DMA_GCARRY) & ~(DMA_COLORFILL_ENABLE | DMA_OPAQUE);
|
|
48
|
+
banksMirror = bankflip | GRAM_PAGE(font_slot);
|
|
49
|
+
*bank_reg = banksMirror;
|
|
50
|
+
vram[WIDTH] = TEXT_CHAR_WIDTH;
|
|
51
|
+
vram[HEIGHT] = TEXT_CHAR_HEIGHT;
|
|
52
|
+
vram[VY] = text_cursor_y;
|
|
53
|
+
while(*str != 0) {
|
|
54
|
+
switch(*str) {
|
|
55
|
+
case ' ':
|
|
56
|
+
text_cursor_x += TEXT_CHAR_WIDTH;
|
|
57
|
+
break;
|
|
58
|
+
case '\n':
|
|
59
|
+
text_cursor_y += TEXT_CHAR_HEIGHT;
|
|
60
|
+
vram[VY] = text_cursor_y;
|
|
61
|
+
break;
|
|
62
|
+
case '\r':
|
|
63
|
+
text_cursor_x = text_print_line_start;
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
text_tmp = *str + text_color;
|
|
67
|
+
if(text_cursor_x >= (text_print_width + text_print_line_start)) {
|
|
68
|
+
text_cursor_x -= text_print_width;
|
|
69
|
+
text_cursor_y += TEXT_CHAR_HEIGHT;
|
|
70
|
+
vram[VY] = text_cursor_y;
|
|
71
|
+
}
|
|
72
|
+
vram[VX] = text_cursor_x;
|
|
73
|
+
vram[GX] = ((text_tmp & 0x0F) << 3) | font_offset_x;
|
|
74
|
+
vram[GY] = ((text_tmp & 0xF0) >> 1) | font_offset_y;
|
|
75
|
+
vram[START] = 1;
|
|
76
|
+
text_cursor_x += TEXT_CHAR_WIDTH;
|
|
77
|
+
wait();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
++str;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
#pragma rodata-name (push, "PROG0")
|
|
85
|
+
|
|
86
|
+
const unsigned char decimal_conversion_table[100] = {
|
|
87
|
+
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
|
88
|
+
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
|
89
|
+
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
|
|
90
|
+
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
|
|
91
|
+
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
|
92
|
+
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
|
93
|
+
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
|
|
94
|
+
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
|
|
95
|
+
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
|
|
96
|
+
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
#pragma rodata-name (pop)
|
|
100
|
+
|
|
101
|
+
void text_sprint_num(char* s, unsigned char num) {
|
|
102
|
+
if(num > 99) return;
|
|
103
|
+
push_rom_bank();
|
|
104
|
+
change_rom_bank(BANK_PROG0);
|
|
105
|
+
num = decimal_conversion_table[num];
|
|
106
|
+
*s = (num >> 4) + '0';
|
|
107
|
+
*(s+1) = (num & 0xF) + '0';
|
|
108
|
+
pop_rom_bank();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifndef TEXT_H
|
|
2
|
+
#define TEXT_H
|
|
3
|
+
|
|
4
|
+
#include "modules_enabled.h"
|
|
5
|
+
|
|
6
|
+
#ifndef ENABLE_MODULE_TEXT
|
|
7
|
+
#error "Module TEXT included but not enabled!"
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#include "sprites.h"
|
|
11
|
+
|
|
12
|
+
#define TEXT_COLOR_BLACK 0
|
|
13
|
+
#define TEXT_COLOR_WHITE 128
|
|
14
|
+
|
|
15
|
+
void text_init();
|
|
16
|
+
|
|
17
|
+
SpriteSlot text_load_font();
|
|
18
|
+
|
|
19
|
+
void text_print_string(char* text);
|
|
20
|
+
void text_sprint_num(char* s, unsigned char num);
|
|
21
|
+
|
|
22
|
+
extern char text_cursor_x, text_cursor_y, text_print_width, text_print_line_start;
|
|
23
|
+
extern unsigned char text_color;
|
|
24
|
+
|
|
25
|
+
#endif
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* GameTank-specific defines
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#ifndef GAMETANK_H
|
|
6
|
+
#define GAMETANK_H
|
|
7
|
+
|
|
8
|
+
typedef char bool;
|
|
9
|
+
#define true 1
|
|
10
|
+
#define false 0
|
|
11
|
+
|
|
12
|
+
#define audio_reset ((char *) 0x2000)
|
|
13
|
+
#define audio_nmi ((char *) 0x2001)
|
|
14
|
+
#define audio_rate ((char *) 0x2006)
|
|
15
|
+
#define dma_flags ((char *) 0x2007)
|
|
16
|
+
#define bank_reg ((char *) 0x2005)
|
|
17
|
+
#define via ((char*) 0x2800)
|
|
18
|
+
#define aram ((unsigned char *) 0x3000)
|
|
19
|
+
#define vram ((unsigned char *) 0x4000)
|
|
20
|
+
#define vram_VX ((char *) 0x4000)
|
|
21
|
+
#define vram_VY ((char *) 0x4001)
|
|
22
|
+
#define vram_GX ((char *) 0x4002)
|
|
23
|
+
#define vram_GY ((char *) 0x4003)
|
|
24
|
+
#define vram_WIDTH ((char *) 0x4004)
|
|
25
|
+
#define vram_HEIGHT ((char *) 0x4005)
|
|
26
|
+
#define vram_COLOR ((char *) 0x4007)
|
|
27
|
+
#define vram_START ((char *) 0x4006)
|
|
28
|
+
|
|
29
|
+
#define SCREEN_WIDTH 128
|
|
30
|
+
#define SCREEN_HEIGHT 128
|
|
31
|
+
|
|
32
|
+
#define DMA_ENABLE 1
|
|
33
|
+
#define DMA_PAGE_OUT 2
|
|
34
|
+
#define DMA_NMI 4
|
|
35
|
+
#define DMA_COLORFILL_ENABLE 8
|
|
36
|
+
#define DMA_GCARRY 16
|
|
37
|
+
#define DMA_CPU_TO_VRAM 32
|
|
38
|
+
#define DMA_IRQ 64
|
|
39
|
+
#define DMA_OPAQUE 128
|
|
40
|
+
|
|
41
|
+
#define BANK_GRAM_MASK 7
|
|
42
|
+
#define BANK_SECOND_FRAMEBUFFER 8
|
|
43
|
+
#define BANK_CLIP_X 16
|
|
44
|
+
#define BANK_CLIP_Y 32
|
|
45
|
+
#define BANK_RAM_MASK 192
|
|
46
|
+
|
|
47
|
+
#define GRAM_PAGE(x) x
|
|
48
|
+
|
|
49
|
+
#define VX 0
|
|
50
|
+
#define VY 1
|
|
51
|
+
#define GX 2
|
|
52
|
+
#define GY 3
|
|
53
|
+
#define WIDTH 4
|
|
54
|
+
#define HEIGHT 5
|
|
55
|
+
#define START 6
|
|
56
|
+
#define COLOR 7
|
|
57
|
+
|
|
58
|
+
#define gamepad_1 ((volatile char *) 0x2008)
|
|
59
|
+
#define gamepad_2 ((volatile char *) 0x2009)
|
|
60
|
+
|
|
61
|
+
#define ORB 0
|
|
62
|
+
#define ORA 1
|
|
63
|
+
#define DDRB 2
|
|
64
|
+
#define DDRA 3
|
|
65
|
+
#define T1C 5
|
|
66
|
+
#define ACR 11
|
|
67
|
+
#define PCR 12
|
|
68
|
+
#define IFR 13
|
|
69
|
+
#define IER 14
|
|
70
|
+
|
|
71
|
+
extern char frameflag, frameflip, flagsMirror, banksMirror, bankflip;
|
|
72
|
+
|
|
73
|
+
void wait();
|
|
74
|
+
void nop5();
|
|
75
|
+
void nop10();
|
|
76
|
+
|
|
77
|
+
#define PROFILER_START(x) via[ORB] = 0x80; via[ORB] = x;
|
|
78
|
+
#define PROFILER_END(x) via[ORB] = 0x80; via[ORB] = x | 0x40;
|
|
79
|
+
|
|
80
|
+
#endif
|