mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-24 20:32:39 +00:00
Added working lazynes scroll.c
This commit is contained in:
parent
a78ac24f81
commit
64db016dc2
@ -1,4 +1,4 @@
|
||||
//KICKC FRAGMENT CACHE 160b017651
|
||||
//KICKC FRAGMENT CACHE 160b015f22
|
||||
//FRAGMENT vbuz1=vbuc1
|
||||
lda #{c1}
|
||||
sta {z1}
|
||||
|
@ -1,9 +1,34 @@
|
||||
//KICKC FRAGMENT CACHE 160b017651
|
||||
//FRAGMENT _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc {c1}
|
||||
//KICKC FRAGMENT CACHE 160b015f22
|
||||
//FRAGMENT vbuz1=vbuc1
|
||||
lda #{c1}
|
||||
sta {z1}
|
||||
//FRAGMENT pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1
|
||||
ldx {z1}
|
||||
inc {c1},x
|
||||
//FRAGMENT vbuz1=_inc_vbuz1
|
||||
inc {z1}
|
||||
//FRAGMENT pbuc1_derefidx_vbuaa=_inc_pbuc1_derefidx_vbuaa
|
||||
tax
|
||||
inc {c1},x
|
||||
//FRAGMENT pbuc1_derefidx_vbuxx=_inc_pbuc1_derefidx_vbuxx
|
||||
inc {c1},x
|
||||
//FRAGMENT vbuaa=vbuc1
|
||||
lda #{c1}
|
||||
//FRAGMENT vbuaa=_inc_vbuaa
|
||||
clc
|
||||
adc #1
|
||||
//FRAGMENT vbuxx=vbuc1
|
||||
ldx #{c1}
|
||||
//FRAGMENT vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//FRAGMENT vbuyy=vbuc1
|
||||
ldy #{c1}
|
||||
//FRAGMENT pbuc1_derefidx_vbuyy=_inc_pbuc1_derefidx_vbuyy
|
||||
tya
|
||||
tax
|
||||
inc {c1},x
|
||||
//FRAGMENT vbuyy=_inc_vbuyy
|
||||
iny
|
||||
//FRAGMENT pbuz1=pbuc1
|
||||
lda #<{c1}
|
||||
sta {z1}
|
||||
@ -45,8 +70,6 @@ lda {z2}
|
||||
sta {z1}
|
||||
lda {z2}+1
|
||||
sta {z1}+1
|
||||
//FRAGMENT vbuz1=_inc_vbuz1
|
||||
inc {z1}
|
||||
//FRAGMENT vbuz1_neq_vbuc1_then_la1
|
||||
lda #{c1}
|
||||
cmp {z1}
|
||||
@ -255,12 +278,6 @@ tay
|
||||
txa
|
||||
and #{c1}
|
||||
tay
|
||||
//FRAGMENT vbuaa=vbuc1
|
||||
lda #{c1}
|
||||
//FRAGMENT vbuxx=vbuc1
|
||||
ldx #{c1}
|
||||
//FRAGMENT vbuyy=vbuc1
|
||||
ldy #{c1}
|
||||
//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx
|
||||
lda {c1},x
|
||||
//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy
|
||||
@ -1280,10 +1297,6 @@ ldy {z1}+1
|
||||
//FRAGMENT vbuyy=vbuaa_band_vbuc1
|
||||
and #{c1}
|
||||
tay
|
||||
//FRAGMENT vbuxx=_inc_vbuxx
|
||||
inx
|
||||
//FRAGMENT vbuyy=_inc_vbuyy
|
||||
iny
|
||||
//FRAGMENT vbuyy_neq_vbuc1_then_la1
|
||||
cpy #{c1}
|
||||
bne {la1}
|
||||
@ -1601,9 +1614,6 @@ sta {c1},x
|
||||
//FRAGMENT vbuaa_neq_vbuc1_then_la1
|
||||
cmp #{c1}
|
||||
bne {la1}
|
||||
//FRAGMENT vbuaa=_inc_vbuaa
|
||||
clc
|
||||
adc #1
|
||||
//FRAGMENT _deref_pbuc1=_deref_pbuc1_bor_vbuc2
|
||||
lda #{c2}
|
||||
ora {c1}
|
||||
@ -1613,6 +1623,8 @@ lda #<{c2}
|
||||
sta {c1}
|
||||
lda #>{c2}
|
||||
sta {c1}+1
|
||||
//FRAGMENT _deref_pbuc1=_inc__deref_pbuc1
|
||||
inc {c1}
|
||||
//FRAGMENT _deref_pbuc1_lt_vbuc2_then_la1
|
||||
lda {c1}
|
||||
cmp #{c2}
|
||||
@ -8006,9 +8018,6 @@ ldy {z1}
|
||||
lda {c1},y
|
||||
cmp #{c2}
|
||||
beq {la1}
|
||||
//FRAGMENT pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1
|
||||
ldx {z1}
|
||||
inc {c1},x
|
||||
//FRAGMENT pbuc1_derefidx_vbuaa_eq_vbuc2_then_la1
|
||||
tay
|
||||
lda {c1},y
|
||||
@ -8022,12 +8031,6 @@ beq {la1}
|
||||
lda {c1},y
|
||||
cmp #{c2}
|
||||
beq {la1}
|
||||
//FRAGMENT pbuc1_derefidx_vbuxx=_inc_pbuc1_derefidx_vbuxx
|
||||
inc {c1},x
|
||||
//FRAGMENT pbuc1_derefidx_vbuyy=_inc_pbuc1_derefidx_vbuyy
|
||||
tya
|
||||
tax
|
||||
inc {c1},x
|
||||
//FRAGMENT vduz1=vduc1_plus_vbuz2
|
||||
lda {z2}
|
||||
clc
|
||||
@ -13791,9 +13794,6 @@ lda {z1}
|
||||
sta {c1}
|
||||
lda {z1}+1
|
||||
sta {c1}+1
|
||||
//FRAGMENT pbuc1_derefidx_vbuaa=_inc_pbuc1_derefidx_vbuaa
|
||||
tax
|
||||
inc {c1},x
|
||||
//FRAGMENT vbuaa=vbuaa_bor_vbuc1
|
||||
ora #{c1}
|
||||
//FRAGMENT vbuz1=_deref_pbuz2_rol_1
|
||||
|
13
src/main/fragment/mos6502-common/vwum1=vwum1_plus_vbsaa.asm
Normal file
13
src/main/fragment/mos6502-common/vwum1=vwum1_plus_vbsaa.asm
Normal file
@ -0,0 +1,13 @@
|
||||
sta $fe
|
||||
ora #$7f
|
||||
bmi !+
|
||||
lda #0
|
||||
!:
|
||||
sta $ff
|
||||
clc
|
||||
lda {m1}
|
||||
adc $fe
|
||||
sta {m1}
|
||||
lda {m1}+1
|
||||
adc $ff
|
||||
sta {m1}+1
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCLexer.g4 by ANTLR 4.7.2
|
||||
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 by ANTLR 4.8
|
||||
package dk.camelot64.kickc.parser;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ import org.antlr.v4.runtime.misc.*;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class KickCLexer extends Lexer {
|
||||
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
|
||||
static { RuntimeMetaData.checkVersion("4.8", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
|
||||
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.8
|
||||
package dk.camelot64.kickc.parser;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
|
||||
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
|
||||
public class KickCParser extends Parser {
|
||||
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
|
||||
static { RuntimeMetaData.checkVersion("4.8", RuntimeMetaData.VERSION); }
|
||||
|
||||
protected static final DFA[] _decisionToDFA;
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
|
||||
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.8
|
||||
package dk.camelot64.kickc.parser;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
|
||||
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.8
|
||||
package dk.camelot64.kickc.parser;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
|
||||
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.8
|
||||
package dk.camelot64.kickc.parser;
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from C:/c64/kickc/src/main/java/dk/camelot64/kickc/parser\KickCParser.g4 by ANTLR 4.7.2
|
||||
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.8
|
||||
package dk.camelot64.kickc.parser;
|
||||
|
||||
|
||||
|
@ -41,6 +41,8 @@ void main() {
|
||||
PPU->PPUCTRL = 0b10001000;
|
||||
// Enable sprite and tile rendering
|
||||
PPU->PPUMASK = 0b00011110;
|
||||
// Reset scroll
|
||||
scroll_x = scroll_y = 0;
|
||||
// Execute lazynes main code
|
||||
lnMain();
|
||||
// Infinite loop
|
||||
@ -69,13 +71,18 @@ 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;
|
||||
|
||||
// Scroll x-position
|
||||
volatile char scroll_x;
|
||||
// Scroll y-position
|
||||
volatile char scroll_y;
|
||||
|
||||
// NMI Called when the PPU refreshes the screen (also known as the V-Blank period)
|
||||
interrupt(hardware_stack) void vblank() {
|
||||
// DMA transfer the entire sprite buffer to the PPU
|
||||
ppuSpriteBufferDmaTransfer(SPRITE_BUFFER);
|
||||
// Set scroll
|
||||
PPU->PPUSCROLL = 0;
|
||||
PPU->PPUSCROLL = 0;
|
||||
PPU->PPUSCROLL = scroll_x;
|
||||
PPU->PPUSCROLL = scroll_y;
|
||||
// count vblanks
|
||||
vblank_count++;
|
||||
// send vblank signal
|
||||
@ -163,13 +170,14 @@ void lnPush(uword o, ubyte a, void* s) {
|
||||
// x: New horizotnal scrolling offset in pixels, allowed range: [0..511]
|
||||
// y: New vertical scrolling offset in pixels, allowed range: [0..479]
|
||||
//
|
||||
// TODO: void lnScroll(uword x, uword y);
|
||||
//
|
||||
// remarks:
|
||||
// - If a SPR0HIT based splitscreen is used, the 1st call of lnScroll() sets
|
||||
// the scrolling offsets of the area above the split and the 2nd call of
|
||||
// lnScroll() sets the scrolling offsets of the area below the split.
|
||||
|
||||
// remarks:
|
||||
// - If a SPR0HIT based splitscreen is used, the 1st call of lnScroll() sets
|
||||
// the scrolling offsets of the area above the split and the 2nd call of
|
||||
// lnScroll() sets the scrolling offsets of the area below the split.
|
||||
void lnScroll(uword x, uword y) {
|
||||
scroll_x = <x;
|
||||
scroll_y = <y;
|
||||
}
|
||||
|
||||
// Add meta-sprite to display list
|
||||
// p: Pointer to metasprite data
|
||||
|
@ -55,24 +55,20 @@ enum { lfHor=64, lfVer=128, lfEnd=255 };
|
||||
|
||||
|
||||
// Common offsets for lnPush() and lnList()
|
||||
enum {
|
||||
lnNameTab0=0x2000, lnNameTab1=0x2400, lnNameTab2=0x2800, lnNameTab3=0x2C00,
|
||||
const uword lnNameTab0=0x2000, lnNameTab1=0x2400, lnNameTab2=0x2800, lnNameTab3=0x2C00,
|
||||
lnAttrTab0=0x23C0, lnAttrTab1=0x27C0, lnAttrTab2=0x2BC0, lnAttrTab3=0x2FC0,
|
||||
lnBackCol=0x3F00,
|
||||
lnChrPal0=0x3F01, lnChrPal1=0x3F05, lnChrPal2=0x3F09, lnChrPal3=0x3F0D,
|
||||
lnSprPal0=0x3F11, lnSprPal1=0x3F15, lnSprPal2=0x3F19, lnSprPal3=0x3F1D
|
||||
};
|
||||
lnSprPal0=0x3F11, lnSprPal1=0x3F15, lnSprPal2=0x3F19, lnSprPal3=0x3F1D;
|
||||
|
||||
// Scroll background
|
||||
// x: New horizotnal scrolling offset in pixels, allowed range: [0..511]
|
||||
// y: New vertical scrolling offset in pixels, allowed range: [0..479]
|
||||
//
|
||||
// TODO: void lnScroll(uword x, uword y);
|
||||
//
|
||||
// remarks:
|
||||
// - If a SPR0HIT based splitscreen is used, the 1st call of lnScroll() sets
|
||||
// the scrolling offsets of the area above the split and the 2nd call of
|
||||
// lnScroll() sets the scrolling offsets of the area below the split.
|
||||
// remarks:
|
||||
// - If a SPR0HIT based splitscreen is used, the 1st call of lnScroll() sets
|
||||
// the scrolling offsets of the area above the split and the 2nd call of
|
||||
// lnScroll() sets the scrolling offsets of the area below the split.
|
||||
void lnScroll(uword x, uword y);
|
||||
|
||||
// Add meta-sprite to display list
|
||||
// p: Pointer to metasprite data
|
||||
|
46
src/test/kc/complex/lazynes/scroll.c
Normal file
46
src/test/kc/complex/lazynes/scroll.c
Normal file
@ -0,0 +1,46 @@
|
||||
// lazyNES scroll demo
|
||||
// lazyNES - As lazy as possible NES hardware support library for vbcc6502
|
||||
// (happily cooperates with Shiru's famitone2 replay code)
|
||||
// V1.0, 'Lazycow 2020
|
||||
|
||||
// Ported to KickC 2020 by Jesper Gravgaard
|
||||
// Original Source VBCC alpha 2 http://www.ibaug.de/vbcc/vbcc6502_2.zip
|
||||
|
||||
#pragma target(nes)
|
||||
#include "lazynes.h"
|
||||
|
||||
int lnMain() {
|
||||
|
||||
static const ubyte bgColors[]={45,33,2};
|
||||
static const ubyte bubblesPal[]={ 0, 37,22,5, 0, 42,26,10, 0, 33,18,3 };
|
||||
|
||||
ubyte i;
|
||||
uword hScroll=0;
|
||||
sbyte hVel=0, hDir=1;
|
||||
|
||||
lnSync(lfBlank); // blank screen to enable lnPush() usage
|
||||
lnPush(lnBackCol,3,bgColors); // set background colors
|
||||
|
||||
// draw some backgrounds
|
||||
{ //
|
||||
static const ubyte g1[]={1}, g2[]={2,3,4,5}, g3[]={6,7,8,9};
|
||||
ubyte x;
|
||||
// draw a line: Sprite #0 will be placed ontop later to trigger the split
|
||||
i=2; for (x=0;x<32;x+=1) lnPush(lnNameTab0+((uword)i<<5)+x,1,g1);
|
||||
// draw some diamond shapes
|
||||
for (i=8;i<=24;i+=4) for (x=0;x<4;x+=1) {
|
||||
lnPush(lnNameTab0+((uword)i<<5)+12+x*4,4,g2);
|
||||
lnPush(lnNameTab0+32+((uword)i<<5)+12+x*4,4,g3);
|
||||
}
|
||||
}
|
||||
lnSync(0);
|
||||
|
||||
for(;;) {
|
||||
lnScroll(hScroll>>6,0); // set scrolling offsets of area below split
|
||||
hVel+=hDir; if (hVel>64 || hVel<-64) hDir=-hDir;
|
||||
hScroll+=hVel;
|
||||
lnSync(0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user