interlace: rasterbars update

This commit is contained in:
Vince Weaver 2019-06-11 15:06:48 -04:00
parent bf90f73077
commit 54e5a912c2
3 changed files with 169 additions and 74 deletions

55
interlace_demo/make_it.c Normal file
View File

@ -0,0 +1,55 @@
#include <stdio.h>
static int gr_offsets[]={
0x400,0x480,0x500,0x580,0x600,0x680,0x700,0x780,
0x428,0x4a8,0x528,0x5a8,0x628,0x6a8,0x728,0x7a8,
0x450,0x4d0,0x550,0x5d0,0x650,0x6d0,0x750,0x7d0,
};
#define X_OFFSET 13
int main(int argc, char **argv) {
int i,j;
for(i=0;i<96;i++) {
printf("; %d\n",i*2);
printf("\tbit\tPAGE0\t; 4\n");
printf("smc%03d:\tlda\t#$00\t; 2\n",i*2);
for(j=0;j<14;j++) {
printf("\tsta\t$%3x\t; 4\n",
gr_offsets[i/4]+0x400+j+X_OFFSET);
}
printf("\tlda\tTEMP\t; 3\n");
printf("\n");
printf("; %d\n",(i*2)+1);
printf("\tbit\tPAGE1\t; 4\n");
printf("smc%03d:\tlda\t#$00\t; 2\n",(i*2)+1);
for(j=0;j<14;j++) {
printf("\tsta\t$%3x\t; 4\n",
gr_offsets[i/4]+j+X_OFFSET);
}
printf("\tlda\tTEMP\t; 3\n");
printf("\n");
}
printf("y_lookup_h:\n");
for(i=32;i<32+128;i++) {
if (i%8==0) printf(".byte\t");
printf(">(smc%03d+1)",i);
if (i%8!=7) printf(",");
else printf("\n");
}
printf("y_lookup_l:\n");
for(i=32;i<32+128;i++) {
if (i%8==0) printf(".byte\t");
printf("<(smc%03d+1)",i);
if (i%8!=7) printf(",");
else printf("\n");
}
return 0;
}

View File

@ -22,6 +22,9 @@ PADDLE_STATUS = $F2
TEMP = $FA TEMP = $FA
WHICH = $FB WHICH = $FB
OUTL = $FE
OUTH = $FF
; Soft Switches ; Soft Switches
KEYPRESS= $C000 KEYPRESS= $C000
@ -171,34 +174,39 @@ loopB: dex ; 2
; vblank = 4550 cycles to do scrolling ; vblank = 4550 cycles to do scrolling
; want colors 01234567
; line 0: $X0 to $800
; line 1: $X1 to $400
; line 2: $X2
; line 3: $X3
; line 4: $4X
; line 5: $5X
; line 6: $6X
; line 7: $7X
display_loop: display_loop:
.include "rasterbars_screen.s" .include "rasterbars_screen.s"
;====================================================== ;======================================================
; We have 4550 cycles in the vblank, use them wisely ; We have 4550 cycles in the vblank, use them wisely
;====================================================== ;======================================================
; do_nothing should be
; 4550
; -6
; -10
;=============
; 4534
jsr do_nothing ; 6 ; 4550 -- VBLANK
; -134 -- raster
; -10 -- keypress
;=======
; 4406
pad_time:
; we erase, then draw
; doing a blanket erase of all 128 lines would cost 3459 cycles!
ldx #10 ; 2
jsr draw_rasterbar ; 6+126
; Try X=175 Y=5 cycles=4406
ldy #5 ; 2
loop1: ldx #175 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
bne loop1 ; 2nt/3
lda KEYPRESS ; 4 lda KEYPRESS ; 4
bpl no_keypress ; 3 bpl no_keypress ; 3
@ -208,42 +216,72 @@ no_keypress:
jmp display_loop ; 3 jmp display_loop ; 3
;========================
; Draw a rasterbar
; unroll as memory is free! haha
;========================
; X is location
;================================= ; 2+22+24+24+24+24+6 = 126
; do nothing
;=================================
; and take 4534-6 = 4528 cycles to do it
draw_rasterbar:
; blah, current code the tight loops are right at a page boundary ; clear all lines
ldy #0 ; 2
;====
do_nothing: lda y_lookup_l,X ; 4
sta OUTL ; 3
lda y_lookup_h,X ; 4
sta OUTH ; 3
; want 4528-12=4516 lda #$33 ; 2
sta (OUTL),Y ; 6
;============
; 22
; Try X=4 Y=174 cycles=4525 R3 -3 X loops inx ; 2
lda y_lookup_l,X ; 4
sta OUTL ; 3
lda y_lookup_h,X ; 4
sta OUTH ; 3
; Try X=3 Y=215 cycles=4516 lda #$bb ; 2
sta (OUTL),Y ; 6
nop ; 2 inx ; 2
nop ; 2 lda y_lookup_l,X ; 4
sta OUTL ; 3
lda y_lookup_h,X ; 4
sta OUTH ; 3
nop ; 2 lda #$ff ; 2
nop ; 2 sta (OUTL),Y ; 6
inx
lda y_lookup_l,X ; 4
sta OUTL ; 3
lda y_lookup_h,X ; 4
sta OUTH ; 3
lda #$bb ; 2
sta (OUTL),Y ; 6
inx
lda y_lookup_l,X ; 4
sta OUTL ; 3
lda y_lookup_h,X ; 4
sta OUTH ; 3
lda #$33 ; 2
sta (OUTL),Y ; 6
rts ; 6
nop ; 2
nop ; 2
ldy #215 ; 2
loop1: ldx #3 ; 2
loop2: dex ; 2
bne loop2 ; 2nt/3
dey ; 2
bne loop1 ; 2nt/3
rts ; 6
@ -303,3 +341,5 @@ pictures:
krg: krg:
.byte $0 .byte $0
red_x: .byte $10

View File

@ -1,34 +1,34 @@
y_lookup_h: y_lookup_h:
.byte >smc032,>smc033,>smc034,>smc035,>smc036,>smc037,>smc038,>smc039 .byte >(smc032+1),>(smc033+1),>(smc034+1),>(smc035+1),>(smc036+1),>(smc037+1),>(smc038+1),>(smc039+1)
.byte >smc040,>smc041,>smc042,>smc043,>smc044,>smc045,>smc046,>smc047 .byte >(smc040+1),>(smc041+1),>(smc042+1),>(smc043+1),>(smc044+1),>(smc045+1),>(smc046+1),>(smc047+1)
.byte >smc048,>smc049,>smc050,>smc051,>smc052,>smc053,>smc054,>smc055 .byte >(smc048+1),>(smc049+1),>(smc050+1),>(smc051+1),>(smc052+1),>(smc053+1),>(smc054+1),>(smc055+1)
.byte >smc056,>smc057,>smc058,>smc059,>smc060,>smc061,>smc062,>smc063 .byte >(smc056+1),>(smc057+1),>(smc058+1),>(smc059+1),>(smc060+1),>(smc061+1),>(smc062+1),>(smc063+1)
.byte >smc064,>smc065,>smc066,>smc067,>smc068,>smc069,>smc070,>smc071 .byte >(smc064+1),>(smc065+1),>(smc066+1),>(smc067+1),>(smc068+1),>(smc069+1),>(smc070+1),>(smc071+1)
.byte >smc072,>smc073,>smc074,>smc075,>smc076,>smc077,>smc078,>smc079 .byte >(smc072+1),>(smc073+1),>(smc074+1),>(smc075+1),>(smc076+1),>(smc077+1),>(smc078+1),>(smc079+1)
.byte >smc080,>smc081,>smc082,>smc083,>smc084,>smc085,>smc086,>smc087 .byte >(smc080+1),>(smc081+1),>(smc082+1),>(smc083+1),>(smc084+1),>(smc085+1),>(smc086+1),>(smc087+1)
.byte >smc088,>smc089,>smc090,>smc091,>smc092,>smc093,>smc094,>smc095 .byte >(smc088+1),>(smc089+1),>(smc090+1),>(smc091+1),>(smc092+1),>(smc093+1),>(smc094+1),>(smc095+1)
.byte >smc096,>smc097,>smc098,>smc099,>smc100,>smc101,>smc102,>smc103 .byte >(smc096+1),>(smc097+1),>(smc098+1),>(smc099+1),>(smc100+1),>(smc101+1),>(smc102+1),>(smc103+1)
.byte >smc104,>smc105,>smc106,>smc107,>smc108,>smc109,>smc110,>smc111 .byte >(smc104+1),>(smc105+1),>(smc106+1),>(smc107+1),>(smc108+1),>(smc109+1),>(smc110+1),>(smc111+1)
.byte >smc112,>smc113,>smc114,>smc115,>smc116,>smc117,>smc118,>smc119 .byte >(smc112+1),>(smc113+1),>(smc114+1),>(smc115+1),>(smc116+1),>(smc117+1),>(smc118+1),>(smc119+1)
.byte >smc120,>smc121,>smc122,>smc123,>smc124,>smc125,>smc126,>smc127 .byte >(smc120+1),>(smc121+1),>(smc122+1),>(smc123+1),>(smc124+1),>(smc125+1),>(smc126+1),>(smc127+1)
.byte >smc128,>smc129,>smc130,>smc131,>smc132,>smc133,>smc134,>smc135 .byte >(smc128+1),>(smc129+1),>(smc130+1),>(smc131+1),>(smc132+1),>(smc133+1),>(smc134+1),>(smc135+1)
.byte >smc136,>smc137,>smc138,>smc139,>smc140,>smc141,>smc142,>smc143 .byte >(smc136+1),>(smc137+1),>(smc138+1),>(smc139+1),>(smc140+1),>(smc141+1),>(smc142+1),>(smc143+1)
.byte >smc144,>smc145,>smc146,>smc147,>smc148,>smc149,>smc150,>smc151 .byte >(smc144+1),>(smc145+1),>(smc146+1),>(smc147+1),>(smc148+1),>(smc149+1),>(smc150+1),>(smc151+1)
.byte >smc152,>smc153,>smc154,>smc155,>smc156,>smc157,>smc158,>smc159 .byte >(smc152+1),>(smc153+1),>(smc154+1),>(smc155+1),>(smc156+1),>(smc157+1),>(smc158+1),>(smc159+1)
y_lookup_l: y_lookup_l:
.byte <smc032,<smc033,<smc034,<smc035,<smc036,<smc037,<smc038,<smc039 .byte <(smc032+1),<(smc033+1),<(smc034+1),<(smc035+1),<(smc036+1),<(smc037+1),<(smc038+1),<(smc039+1)
.byte <smc040,<smc041,<smc042,<smc043,<smc044,<smc045,<smc046,<smc047 .byte <(smc040+1),<(smc041+1),<(smc042+1),<(smc043+1),<(smc044+1),<(smc045+1),<(smc046+1),<(smc047+1)
.byte <smc048,<smc049,<smc050,<smc051,<smc052,<smc053,<smc054,<smc055 .byte <(smc048+1),<(smc049+1),<(smc050+1),<(smc051+1),<(smc052+1),<(smc053+1),<(smc054+1),<(smc055+1)
.byte <smc056,<smc057,<smc058,<smc059,<smc060,<smc061,<smc062,<smc063 .byte <(smc056+1),<(smc057+1),<(smc058+1),<(smc059+1),<(smc060+1),<(smc061+1),<(smc062+1),<(smc063+1)
.byte <smc064,<smc065,<smc066,<smc067,<smc068,<smc069,<smc070,<smc071 .byte <(smc064+1),<(smc065+1),<(smc066+1),<(smc067+1),<(smc068+1),<(smc069+1),<(smc070+1),<(smc071+1)
.byte <smc072,<smc073,<smc074,<smc075,<smc076,<smc077,<smc078,<smc079 .byte <(smc072+1),<(smc073+1),<(smc074+1),<(smc075+1),<(smc076+1),<(smc077+1),<(smc078+1),<(smc079+1)
.byte <smc080,<smc081,<smc082,<smc083,<smc084,<smc085,<smc086,<smc087 .byte <(smc080+1),<(smc081+1),<(smc082+1),<(smc083+1),<(smc084+1),<(smc085+1),<(smc086+1),<(smc087+1)
.byte <smc088,<smc089,<smc090,<smc091,<smc092,<smc093,<smc094,<smc095 .byte <(smc088+1),<(smc089+1),<(smc090+1),<(smc091+1),<(smc092+1),<(smc093+1),<(smc094+1),<(smc095+1)
.byte <smc096,<smc097,<smc098,<smc099,<smc100,<smc101,<smc102,<smc103 .byte <(smc096+1),<(smc097+1),<(smc098+1),<(smc099+1),<(smc100+1),<(smc101+1),<(smc102+1),<(smc103+1)
.byte <smc104,<smc105,<smc106,<smc107,<smc108,<smc109,<smc110,<smc111 .byte <(smc104+1),<(smc105+1),<(smc106+1),<(smc107+1),<(smc108+1),<(smc109+1),<(smc110+1),<(smc111+1)
.byte <smc112,<smc113,<smc114,<smc115,<smc116,<smc117,<smc118,<smc119 .byte <(smc112+1),<(smc113+1),<(smc114+1),<(smc115+1),<(smc116+1),<(smc117+1),<(smc118+1),<(smc119+1)
.byte <smc120,<smc121,<smc122,<smc123,<smc124,<smc125,<smc126,<smc127 .byte <(smc120+1),<(smc121+1),<(smc122+1),<(smc123+1),<(smc124+1),<(smc125+1),<(smc126+1),<(smc127+1)
.byte <smc128,<smc129,<smc130,<smc131,<smc132,<smc133,<smc134,<smc135 .byte <(smc128+1),<(smc129+1),<(smc130+1),<(smc131+1),<(smc132+1),<(smc133+1),<(smc134+1),<(smc135+1)
.byte <smc136,<smc137,<smc138,<smc139,<smc140,<smc141,<smc142,<smc143 .byte <(smc136+1),<(smc137+1),<(smc138+1),<(smc139+1),<(smc140+1),<(smc141+1),<(smc142+1),<(smc143+1)
.byte <smc144,<smc145,<smc146,<smc147,<smc148,<smc149,<smc150,<smc151 .byte <(smc144+1),<(smc145+1),<(smc146+1),<(smc147+1),<(smc148+1),<(smc149+1),<(smc150+1),<(smc151+1)
.byte <smc152,<smc153,<smc154,<smc155,<smc156,<smc157,<smc158,<smc159 .byte <(smc152+1),<(smc153+1),<(smc154+1),<(smc155+1),<(smc156+1),<(smc157+1),<(smc158+1),<(smc159+1)