@@ -97,8 +97,6 @@ in prg {
9797 snes.dma.mdma_enable = a = snes.dma.ENABLE_0;
9898 }
9999
100- far func bar() {}
101-
102100 #[fallthrough] func main() {
103101 nointerrupt = true;
104102 decimal = false;
@@ -111,109 +109,101 @@ in prg {
111109
112110 hardware_init();
113111
114- /*a = *wow2;
115- *wow2 = a;
116- wow2[yy] = a;
117- a = wow2[yy];
118- while true {}
119- goto bar;
120- bar();
121- goto (far &main as far func);
122- goto wow3;
123- ^goto (&wow3 as func);
124- goto *(&wow3 as *func);
125- goto *((&wow3 as u16 + xx) as *func);
126- (*((&wow3 as u16 + xx) as *func))();
127- goto *(&wow4 as *far func);
128- goto wow4; // FIXME: should be equivalent to 'goto *(&wow4 as *far func);'
129- */
130-
131- w0 = xx = &spc_main[0] as u16;
132- xx = 0x200;
133- yy = spc_main.len - 2;
134- snes2spc.transfer(xx, w0, yy);
135- xx = *(&spc_main[spc_main.len - 2] as *u16);
136- snes2spc.dispatch(xx);
137-
138- snes.ppu.vram_control = a = snes.ppu.VRAM_CONTROL_INCREMENT_1 | snes.ppu.VRAM_CONTROL_SIZE_16;
139- snes.ppu.vram_address_hl = xx = 0;
140-
141- snes.dma0.control = a = snes.dma.CONTROL_MODE_AB;
142- snes.dma0.mdma_dest = a = <:&snes.ppu.vram_write_data_l;
143- snes.dma0.src_address_hl = xx = &hello_tiles_chr as u16;
144- snes.dma0.src_address_bank = 0;
145- snes.dma0.mdma_size_hl = xx = sizeof(typeof(hello_tiles_chr)) / sizeof(u16);
146-
147- snes.ppu.cgram_address = 0;
148-
149- snes.dma1.control = a = snes.dma.CONTROL_MODE_A;
150- snes.dma1.mdma_dest = a = <:&snes.ppu.cgram_write_data;
151- snes.dma1.src_address_hl = xx = &bkg_palette_data as u16;
152- snes.dma1.src_address_bank = 0;
153- snes.dma1.mdma_size_hl = xx = sizeof(typeof(bkg_palette_data));
154-
155- snes.dma.mdma_enable = a = snes.dma.ENABLE_0 | snes.dma.ENABLE_1;
156-
157- let BG1_TILEMAP_BASE_ADDRESS = 0x1000;
158- let BG12_TILESET_BASE_ADDRESS = 0x0000;
159-
160- let TEXT_X = 10;
161- let TEXT_Y = 13;
162- let TEXT_TILEMAP_DEST = BG1_TILEMAP_BASE_ADDRESS + TEXT_Y * 32 + TEXT_X;
163-
164- snes.ppu.vram_control = a = snes.ppu.VRAM_CONTROL_INCREMENT_1 | snes.ppu.VRAM_CONTROL_SIZE_8;
165- snes.ppu.vram_address_hl = xx = TEXT_TILEMAP_DEST;
166-
167- snes.dma0.control = a = snes.dma.CONTROL_MODE_A;
168- snes.dma0.mdma_dest = a = <:&snes.ppu.vram_write_data_l;
169- snes.dma0.src_address_hl = xx = &message as u16;
170- snes.dma0.src_address_bank = 0;
171- snes.dma0.mdma_size_hl = xx = sizeof(typeof(message));
172-
173- snes.dma.mdma_enable = a = snes.dma.ENABLE_0;
174-
175- snes.ppu.bg1_tilemap = a = BG1_TILEMAP_BASE_ADDRESS >> snes.ppu.BG_TILEMAP_ADDRESS_BIT_ALIGN << snes.ppu.BG_TILEMAP_ADDRESS_SHIFT_LEFT;
176- snes.ppu.bg12_tileset = a = BG12_TILESET_BASE_ADDRESS >> snes.ppu.BG_TILESET_ADDRESS_BIT_ALIGN;
177- snes.ppu.bg_mode = a = 2;
178- snes.ppu.screen_enable_mask = a = snes.ppu.SCREEN_ENABLE_BG1;
179- snes.ppu.brightness = a = 0xF;
180-
181- mosaic = 0;
182-
183- while true {
184- while !snes.ppu.hvbjoy_status $ snes.ppu.HVBJOY_STATUS_VBLANK_BIT {}
185-
186- snes.ppu.mosaic = a = ((mosaic >>> 4) << 4) | 0x1;
187- mosaic = a = mosaic + 0x08;
188-
189- a = timer;
190-
191- mem16();
192- #[mem16] {
193- aa &= 0xFF;
194- yy = aa <<= 1;
195- }
196- mem8();
197-
198- xx = *((&sine_table as u16 + yy) as *u16);
199- w0 = xx;
200-
201- mem16();
202- #[mem16] {
203- aa = w0;
204-
205- inline for in 1 .. 10 { cmp(aa, 0x8000); aa >>>>#= 1; }
206-
207- w0 = aa;
208- }
209- mem8();
210-
211- snes.ppu.bg1_scroll_y = a = <:w0;
212- snes.ppu.bg1_scroll_y = a = >:w0;
213- ++timer;
214-
215- while snes.ppu.hvbjoy_status $ snes.ppu.HVBJOY_STATUS_VBLANK_BIT {}
112+ snes.rom.speed = a = snes.rom.SPEED_FAST;
113+
114+ push(a = 0x80);
115+ data_bank = pop();
116+
117+ return fast_main();
118+ }
119+ }
120+
121+ #[fallthrough, mem8, idx16] far func fast_main() {
122+ w0 = xx = &spc_main[0] as u16;
123+ xx = 0x200;
124+ yy = spc_main.len - 2;
125+ snes2spc.transfer(xx, w0, yy);
126+ xx = *(&spc_main[spc_main.len - 2] as *u16);
127+ snes2spc.dispatch(xx);
128+
129+ snes.ppu.vram_control = a = snes.ppu.VRAM_CONTROL_INCREMENT_1 | snes.ppu.VRAM_CONTROL_SIZE_16;
130+ snes.ppu.vram_address_hl = xx = 0;
131+
132+ snes.dma0.control = a = snes.dma.CONTROL_MODE_AB;
133+ snes.dma0.mdma_dest = a = <:&snes.ppu.vram_write_data_l;
134+ snes.dma0.src_address_hl = xx = &hello_tiles_chr as u16;
135+ snes.dma0.src_address_bank = 0;
136+ snes.dma0.mdma_size_hl = xx = sizeof(typeof(hello_tiles_chr)) / sizeof(u16);
137+
138+ snes.ppu.cgram_address = 0;
139+
140+ snes.dma1.control = a = snes.dma.CONTROL_MODE_A;
141+ snes.dma1.mdma_dest = a = <:&snes.ppu.cgram_write_data;
142+ snes.dma1.src_address_hl = xx = &bkg_palette_data as u16;
143+ snes.dma1.src_address_bank = 0;
144+ snes.dma1.mdma_size_hl = xx = sizeof(typeof(bkg_palette_data));
145+
146+ snes.dma.mdma_enable = a = snes.dma.ENABLE_0 | snes.dma.ENABLE_1;
147+
148+ let BG1_TILEMAP_BASE_ADDRESS = 0x1000;
149+ let BG12_TILESET_BASE_ADDRESS = 0x0000;
150+
151+ let TEXT_X = 10;
152+ let TEXT_Y = 13;
153+ let TEXT_TILEMAP_DEST = BG1_TILEMAP_BASE_ADDRESS + TEXT_Y * 32 + TEXT_X;
154+
155+ snes.ppu.vram_control = a = snes.ppu.VRAM_CONTROL_INCREMENT_1 | snes.ppu.VRAM_CONTROL_SIZE_8;
156+ snes.ppu.vram_address_hl = xx = TEXT_TILEMAP_DEST;
157+
158+ snes.dma0.control = a = snes.dma.CONTROL_MODE_A;
159+ snes.dma0.mdma_dest = a = <:&snes.ppu.vram_write_data_l;
160+ snes.dma0.src_address_hl = xx = &message as u16;
161+ snes.dma0.src_address_bank = 0;
162+ snes.dma0.mdma_size_hl = xx = sizeof(typeof(message));
163+
164+ snes.dma.mdma_enable = a = snes.dma.ENABLE_0;
165+
166+ snes.ppu.bg1_tilemap = a = BG1_TILEMAP_BASE_ADDRESS >> snes.ppu.BG_TILEMAP_ADDRESS_BIT_ALIGN << snes.ppu.BG_TILEMAP_ADDRESS_SHIFT_LEFT;
167+ snes.ppu.bg12_tileset = a = BG12_TILESET_BASE_ADDRESS >> snes.ppu.BG_TILESET_ADDRESS_BIT_ALIGN;
168+ snes.ppu.bg_mode = a = 2;
169+ snes.ppu.screen_enable_mask = a = snes.ppu.SCREEN_ENABLE_BG1;
170+ snes.ppu.brightness = a = 0xF;
171+
172+ mosaic = 0;
173+
174+ while true {
175+ while !snes.ppu.hvbjoy_status $ snes.ppu.HVBJOY_STATUS_VBLANK_BIT {}
176+
177+ snes.ppu.mosaic = a = ((mosaic >>> 4) << 4) | 0x1;
178+ mosaic = a = mosaic + 0x08;
179+
180+ a = timer;
181+
182+ mem16();
183+ #[mem16] {
184+ aa &= 0xFF;
185+ yy = aa <<= 1;
216186 }
187+ mem8();
188+
189+ xx = *((&sine_table as u16 + yy) as *u16);
190+ w0 = xx;
191+
192+ mem16();
193+ #[mem16] {
194+ aa = w0;
195+
196+ inline for in 1 .. 10 { cmp(aa, 0x8000); aa >>>>#= 1; }
197+
198+ w0 = aa;
199+ }
200+ mem8();
201+
202+ snes.ppu.bg1_scroll_y = a = <:w0;
203+ snes.ppu.bg1_scroll_y = a = >:w0;
204+ ++timer;
205+
206+ while snes.ppu.hvbjoy_status $ snes.ppu.HVBJOY_STATUS_VBLANK_BIT {}
217207 }
218208 }
219209
@@ -234,5 +224,5 @@ in prg {
234224 const minirpg_sprites_chr = embed "minirpg_sprites.chr";
235225 const spc_main = embed "spc_main.bin";
236226
237- const @ 0xFFFC = main;
227+ const @ 0x80FFFC = main;
238228}
0 commit comments