mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-26 12:49:21 +00:00
Working on lazynes.
This commit is contained in:
parent
7384fb5357
commit
1852630b16
@ -1,4 +1,4 @@
|
|||||||
//KICKC FRAGMENT CACHE 160b017651
|
//KICKC FRAGMENT CACHE 160b015f22
|
||||||
//FRAGMENT vbuz1=vbuc1
|
//FRAGMENT vbuz1=vbuc1
|
||||||
lda #{c1}
|
lda #{c1}
|
||||||
sta {z1}
|
sta {z1}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
//KICKC FRAGMENT CACHE 160b017651
|
//KICKC FRAGMENT CACHE 160b015f22
|
||||||
//FRAGMENT vbuz1=vbuc1
|
//FRAGMENT vbuz1=vbuc1
|
||||||
lda #{c1}
|
lda #{c1}
|
||||||
sta {z1}
|
sta {z1}
|
||||||
@ -8562,6 +8562,52 @@ sty {z1}
|
|||||||
//FRAGMENT _deref_pbsc1=vbsc2
|
//FRAGMENT _deref_pbsc1=vbsc2
|
||||||
lda #{c2}
|
lda #{c2}
|
||||||
sta {c1}
|
sta {c1}
|
||||||
|
//FRAGMENT vbuz1=_dec_vbuz2
|
||||||
|
ldy {z2}
|
||||||
|
dey
|
||||||
|
sty {z1}
|
||||||
|
//FRAGMENT vbuz1=_dec_vbuaa
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
|
sta {z1}
|
||||||
|
//FRAGMENT vbuz1=_dec_vbuxx
|
||||||
|
dex
|
||||||
|
stx {z1}
|
||||||
|
//FRAGMENT vbuz1=_dec_vbuyy
|
||||||
|
dey
|
||||||
|
sty {z1}
|
||||||
|
//FRAGMENT vbuaa=_dec_vbuz1
|
||||||
|
lda {z1}
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
|
//FRAGMENT vbuaa=_dec_vbuxx
|
||||||
|
txa
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
|
//FRAGMENT vbuaa=_dec_vbuyy
|
||||||
|
tya
|
||||||
|
sec
|
||||||
|
sbc #1
|
||||||
|
//FRAGMENT vbuxx=_dec_vbuz1
|
||||||
|
ldx {z1}
|
||||||
|
dex
|
||||||
|
//FRAGMENT vbuxx=_dec_vbuaa
|
||||||
|
tax
|
||||||
|
dex
|
||||||
|
//FRAGMENT vbuxx=_dec_vbuyy
|
||||||
|
tya
|
||||||
|
tax
|
||||||
|
dex
|
||||||
|
//FRAGMENT vbuyy=_dec_vbuz1
|
||||||
|
ldy {z1}
|
||||||
|
dey
|
||||||
|
//FRAGMENT vbuyy=_dec_vbuaa
|
||||||
|
tay
|
||||||
|
dey
|
||||||
|
//FRAGMENT vbuyy=_dec_vbuxx
|
||||||
|
txa
|
||||||
|
tay
|
||||||
|
dey
|
||||||
//FRAGMENT vwuz1=vwuz2_bor_vbuz3
|
//FRAGMENT vwuz1=vwuz2_bor_vbuz3
|
||||||
lda {z3}
|
lda {z3}
|
||||||
ora {z2}
|
ora {z2}
|
||||||
@ -17737,49 +17783,3 @@ sta {c1},x
|
|||||||
lda #{c2}
|
lda #{c2}
|
||||||
ora {c1},y
|
ora {c1},y
|
||||||
sta {c1},y
|
sta {c1},y
|
||||||
//FRAGMENT vbuz1=_dec_vbuz2
|
|
||||||
ldy {z2}
|
|
||||||
dey
|
|
||||||
sty {z1}
|
|
||||||
//FRAGMENT vbuz1=_dec_vbuaa
|
|
||||||
sec
|
|
||||||
sbc #1
|
|
||||||
sta {z1}
|
|
||||||
//FRAGMENT vbuz1=_dec_vbuxx
|
|
||||||
dex
|
|
||||||
stx {z1}
|
|
||||||
//FRAGMENT vbuz1=_dec_vbuyy
|
|
||||||
dey
|
|
||||||
sty {z1}
|
|
||||||
//FRAGMENT vbuaa=_dec_vbuz1
|
|
||||||
lda {z1}
|
|
||||||
sec
|
|
||||||
sbc #1
|
|
||||||
//FRAGMENT vbuaa=_dec_vbuxx
|
|
||||||
txa
|
|
||||||
sec
|
|
||||||
sbc #1
|
|
||||||
//FRAGMENT vbuaa=_dec_vbuyy
|
|
||||||
tya
|
|
||||||
sec
|
|
||||||
sbc #1
|
|
||||||
//FRAGMENT vbuxx=_dec_vbuz1
|
|
||||||
ldx {z1}
|
|
||||||
dex
|
|
||||||
//FRAGMENT vbuxx=_dec_vbuaa
|
|
||||||
tax
|
|
||||||
dex
|
|
||||||
//FRAGMENT vbuxx=_dec_vbuyy
|
|
||||||
tya
|
|
||||||
tax
|
|
||||||
dex
|
|
||||||
//FRAGMENT vbuyy=_dec_vbuz1
|
|
||||||
ldy {z1}
|
|
||||||
dey
|
|
||||||
//FRAGMENT vbuyy=_dec_vbuaa
|
|
||||||
tay
|
|
||||||
dey
|
|
||||||
//FRAGMENT vbuyy=_dec_vbuxx
|
|
||||||
txa
|
|
||||||
tay
|
|
||||||
dey
|
|
||||||
|
@ -58,6 +58,17 @@ struct SpriteData align(0x100) SPRITE_BUFFER[0x40];
|
|||||||
// Index of the next SpriteData in SPRITE_BUFFER to write to in lnAddSpr()
|
// Index of the next SpriteData in SPRITE_BUFFER to write to in lnAddSpr()
|
||||||
volatile char add_sprite_idx;
|
volatile char add_sprite_idx;
|
||||||
|
|
||||||
|
// Counts the vblanks between syncs
|
||||||
|
volatile char vblank_count;
|
||||||
|
|
||||||
|
// The current mode set by lnSync.
|
||||||
|
// lfBlank = 1, activates blank mode, blanks screen and allows lnPush() calls
|
||||||
|
// lfSplit = 2 activates split mode, NMI waits for SPR0HIT and sets registers
|
||||||
|
volatile char sync_mode;
|
||||||
|
|
||||||
|
// Signal when vblank occurs. The NMI sets this to zero. To wait for a vblank set this no non-zero and wait for it to become zero.
|
||||||
|
volatile char vblank_signal;
|
||||||
|
|
||||||
// NMI Called when the PPU refreshes the screen (also known as the V-Blank period)
|
// NMI Called when the PPU refreshes the screen (also known as the V-Blank period)
|
||||||
interrupt(hardware_stack) void vblank() {
|
interrupt(hardware_stack) void vblank() {
|
||||||
// DMA transfer the entire sprite buffer to the PPU
|
// DMA transfer the entire sprite buffer to the PPU
|
||||||
@ -65,36 +76,58 @@ interrupt(hardware_stack) void vblank() {
|
|||||||
// Set scroll
|
// Set scroll
|
||||||
PPU->PPUSCROLL = 0;
|
PPU->PPUSCROLL = 0;
|
||||||
PPU->PPUSCROLL = 0;
|
PPU->PPUSCROLL = 0;
|
||||||
// move all sprites off the screen
|
// count vblanks
|
||||||
//for(char i=0;i!=0x40;i++)
|
vblank_count++;
|
||||||
// SPRITE_BUFFER[i].y = 0xff;
|
// send vblank signal
|
||||||
// Reset the index of sprites to add
|
vblank_signal = 0;
|
||||||
add_sprite_idx = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for next vblank
|
// Wait for next vblank
|
||||||
// flags: 0, lfBlank or lfSplit (see below)
|
// flags: 0, lfBlank or lfSplit (see below)
|
||||||
// result: Amount of frames since last sync [0..31], 128 is added on NTSC
|
// result: Amount of frames since last sync [0..31], 128 is added on NTSC
|
||||||
//
|
// lfBlank = 0, disables blank mode (if set), wait for vblank
|
||||||
|
// lfBlank = 1, activates blank mode, blanks screen and allows lnPush() calls
|
||||||
|
// lfSplit = 2 activates split mode, NMI waits for SPR0HIT and sets registers
|
||||||
ubyte lnSync(ubyte flags) {
|
ubyte lnSync(ubyte flags) {
|
||||||
// Enable video output if lfBlank not set
|
// Is video output enabled (lfBlank==0)
|
||||||
if(!(flags&lfBlank)) {
|
if(!(flags&lfBlank)) {
|
||||||
|
// Move remaining sprites off the screen
|
||||||
|
for(char i=add_sprite_idx;i!=0x40;i++)
|
||||||
|
SPRITE_BUFFER[i].y = 0xff;
|
||||||
|
// Reset add sprite index
|
||||||
|
add_sprite_idx = 0;
|
||||||
|
// Enable video output (if it was disabled)
|
||||||
|
if(sync_mode&lfBlank) {
|
||||||
// Set sprite tileset to upper - enable vblank NMI
|
// Set sprite tileset to upper - enable vblank NMI
|
||||||
PPU->PPUCTRL = 0b10001000;
|
PPU->PPUCTRL = 0b10001000;
|
||||||
// Enable sprite and tile rendering
|
// Enable sprite and tile rendering
|
||||||
PPU->PPUMASK = 0b00011110;
|
PPU->PPUMASK = 0b00011110;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for V-Blank signal from the NMI (if vblank is currently enabled)
|
||||||
|
if(!(sync_mode&lfBlank)) {
|
||||||
|
vblank_signal = 0xff;
|
||||||
|
while(vblank_signal) ;
|
||||||
|
}
|
||||||
|
|
||||||
// Wait for V-Blank
|
|
||||||
waitForVBlank();
|
|
||||||
// Disable video output if lfBlank set
|
// Disable video output if lfBlank set
|
||||||
if(flags&lfBlank)
|
if(flags&lfBlank) {
|
||||||
// lfBlank = 1, activates blank mode, blanks screen and allows lnPush() calls
|
// lfBlank = 1, activates blank mode, blanks screen and allows lnPush() calls
|
||||||
disableVideoOutput();
|
// Disable vertical blank interrupt
|
||||||
|
PPU->PPUCTRL = 0;
|
||||||
|
// Disable sprite rendering
|
||||||
|
PPU->PPUMASK = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the mode
|
||||||
|
sync_mode = flags;
|
||||||
|
|
||||||
// TODO: Handle lfSplit = 2 : activates split mode, NMI waits for SPR0HIT and sets registers
|
// TODO: Handle lfSplit = 2 : activates split mode, NMI waits for SPR0HIT and sets registers
|
||||||
// TODO: Count frames
|
// Return number of vblank since last sync
|
||||||
return 0;
|
char res = vblank_count;
|
||||||
|
vblank_count = 0;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write data into nametables, palettes, CHRRAM, etc.
|
// Write data into nametables, palettes, CHRRAM, etc.
|
||||||
|
Loading…
Reference in New Issue
Block a user