mode7: add initial rasterbars code

This commit is contained in:
Vince Weaver 2018-01-13 00:59:53 -05:00
parent c11bc0b1f8
commit d8de617a06
6 changed files with 301 additions and 20 deletions

View File

@ -24,7 +24,7 @@ int set_row_color(double offset, int color) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ch,i=0,j; int ch,i=0,j,end=3;
grsim_init(); grsim_init();
@ -61,7 +61,11 @@ int main(int argc, char **argv) {
i++; i++;
if (i>ELEMENTS-1) i=0; if (i>ELEMENTS-1) {
i=0;
end--;
if (end==0) break;
}
} }
return 0; return 0;

View File

@ -9,7 +9,7 @@ static int row_color[40];
#define ELEMENTS 64 #define ELEMENTS 64
int fixed_sin[ELEMENTS][2]={ static int fixed_sin[ELEMENTS][2]={
{0x00,0x00}, // 0.000000 {0x00,0x00}, // 0.000000
{0x00,0x19}, // 0.098017 {0x00,0x19}, // 0.098017
{0x00,0x31}, // 0.195090 {0x00,0x31}, // 0.195090
@ -26,7 +26,7 @@ int fixed_sin[ELEMENTS][2]={
{0x00,0xF4}, // 0.956940 {0x00,0xF4}, // 0.956940
{0x00,0xFB}, // 0.980785 {0x00,0xFB}, // 0.980785
{0x00,0xFE}, // 0.995185 {0x00,0xFE}, // 0.995185
{0x01,0x00}, // 1.000000 {0x00,0xFF}, // 1.000000
{0x00,0xFE}, // 0.995185 {0x00,0xFE}, // 0.995185
{0x00,0xFB}, // 0.980785 {0x00,0xFB}, // 0.980785
{0x00,0xF4}, // 0.956940 {0x00,0xF4}, // 0.956940
@ -76,9 +76,9 @@ int fixed_sin[ELEMENTS][2]={
{0xFF,0xE7}, // -0.098017 {0xFF,0xE7}, // -0.098017
}; };
int set_row_color(int offset, int color) { static int set_row_color(int offset, int color) {
int y,s=0; int y=0,s=0;
short x; short x;
@ -100,7 +100,7 @@ int set_row_color(int offset, int color) {
int main(int argc, char **argv) { int main(int argc, char **argv) {
int ch,i=0,j; int ch,i=0,j,end=3;
grsim_init(); grsim_init();
@ -114,14 +114,14 @@ int main(int argc, char **argv) {
gr(); gr();
set_row_color(i+7,14); // aqua set_row_color(i+0,14); // aqua
set_row_color(i+6,6); // med-blue set_row_color(i+1,6); // med-blue
set_row_color(i+5,12); // light-green set_row_color(i+2,12); // light-green
set_row_color(i+4,4); // green set_row_color(i+3,4); // green
set_row_color(i+3,13); // yellow set_row_color(i+4,13); // yellow
set_row_color(i+2,9); // orange set_row_color(i+5,9); // orange
set_row_color(i+1,11); // pink set_row_color(i+6,11); // pink
set_row_color(i+0.0,1); // red set_row_color(i+7,1); // red
for(j=0;j<40;j++) { for(j=0;j<40;j++) {
if (row_color[j]) { if (row_color[j]) {
@ -131,12 +131,17 @@ int main(int argc, char **argv) {
} }
grsim_update(); grsim_update();
ch=grsim_input(); ch=grsim_input();
if (ch=='q') exit(0); if (ch=='q') exit(0);
usleep(100000); usleep(100000);
i++; i++;
if (i>ELEMENTS-1) i=0; if (i>(ELEMENTS-1)) {
i=0;
end--;
if (end==0) break;
}
// printf("\n"); // printf("\n");
} }

View File

@ -10,12 +10,13 @@ $(DOS33):
cd ../dos33fs-utils && make cd ../dos33fs-utils && make
mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \ mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
PLOT_TEST SCROLL_DEMO SKY_DEMO STARFIELD_DEMO \ PLOT_TEST RASTERBARS SCROLL_DEMO SKY_DEMO \
STARFIELD_1K STARFIELD_DEMO STARFIELD_1K
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_ISLAND $(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_ISLAND
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_CHECKERBOARD $(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_CHECKERBOARD
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_RAINBOW $(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_RAINBOW
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 PLOT_TEST $(DOS33) -y mode7.dsk BSAVE -a 0x1000 PLOT_TEST
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 RASTERBARS
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SCROLL_DEMO $(DOS33) -y mode7.dsk BSAVE -a 0x1000 SCROLL_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SKY_DEMO $(DOS33) -y mode7.dsk BSAVE -a 0x1000 SKY_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_DEMO $(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_DEMO
@ -113,8 +114,20 @@ starfield_demo.o: starfield_demo.s \
../asm_routines/gr_fast_clear.s ../asm_routines/gr_fast_clear.s
ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst
RASTERBARS: rasterbars.o
ld65 -o RASTERBARS rasterbars.o -C ./apple2_1000.inc
rasterbars.o: rasterbars.s \
../asm_routines/gr_scroll.s \
../asm_routines/pageflip.s \
../asm_routines/gr_setpage.s \
../asm_routines/gr_fast_clear.s
ca65 -o rasterbars.o rasterbars.s -l rasterbars.lst
STARFIELD_1K: starfield_1k.o STARFIELD_1K: starfield_1k.o
ld65 -o STARFIELD_1K starfield_demo.o -C ./apple2_1000.inc ld65 -o STARFIELD_1K starfield_1k.o -C ./apple2_1000.inc
starfield_1k.o: starfield_1k.s \ starfield_1k.o: starfield_1k.s \
../asm_routines/gr_scroll.s \ ../asm_routines/gr_scroll.s \
@ -138,5 +151,5 @@ background.o: background.c
clean: clean:
rm -f *~ *.o scroller background \ rm -f *~ *.o scroller background \
MODE7 MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \ MODE7 MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
PLOT_TEST SCROLL_DEMO STARFIELD_DEMO STARFIELD_1K *.lst PLOT_TEST RASTERBARS SCROLL_DEMO STARFIELD_DEMO STARFIELD_1K *.lst

Binary file not shown.

257
mode7/rasterbars.s Normal file
View File

@ -0,0 +1,257 @@
; Not quite a raster-bar, but why not
.include "zp.inc"
;===========
; CONSTANTS
;===========
ELEMENTS EQU 64
;=====================
; Rasterbars
;=====================
;================================
; Clear screen and setup graphics
;================================
jsr clear_screens ; clear top/bottom of page 0/1
jsr set_gr_page0
;===============
; Init Variables
;===============
lda #0 ; 2
sta DRAW_PAGE ; 3
sta SCREEN_Y
;===========================
;===========================
; Main Loop
;===========================
;===========================
raster_loop:
; clear rows
ldy #19 ; 2
lda #0
init_rows:
sta row_color,Y
dey
bpl init_rows
jsr clear_top
;================
; set colors
lda #COLOR_BOTH_AQUA ; aqua
sta COLOR
ldy SCREEN_Y
jsr set_row_color
; lda #6 ; medium blue
; iny
; jsr set_row_color
;=================
; draw rows
ldy #19
draw_rows_loop:
lda row_color,Y
sta COLOR
tya
pha
asl
ldy #39 ; 2
sty V2 ; 3
ldy #0 ; 2
jsr hlin_double ; hlin y,V2 at A ; 63+(X*16)
pla ; 4
tay
dey
bpl draw_rows_loop
;==================
; flip pages
;==================
jsr page_flip ; 6
;==================
; delay?
;==================
;==================
; update y pointer
;==================
ldy SCREEN_Y
iny
cpy #ELEMENTS
bne not_there
ldy #0
not_there:
sty SCREEN_Y
;==================
; loop forever
;==================
jmp raster_loop ; 3
;===================
; set_row_color
;===================
; color in COLOR
; Y=offset
; Y preserved?
set_row_color:
tya
and #(ELEMENTS-1)
tax
lda fine_sine,X
cpx #33
bpl sin_negative
sin_positive:
clc
ror
clc
ror
clc
ror
clc
ror
clc
adc #18
lsr
tax
lda COLOR
sta row_color,X
jmp sin_no_more
; FIXME: precalculate as we shift same each time
sin_negative:
sec
ror
sec
ror
sec
ror
sec
ror
clc
adc #18
lsr
tax
lda COLOR
sta row_color,X
sin_no_more:
rts
;===============================================
; External modules
;===============================================
.include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s"
;.include "../asm_routines/keypress.s"
.include "../asm_routines/gr_offsets.s"
.include "../asm_routines/gr_fast_clear.s"
.include "../asm_routines/gr_hlin.s"
;======================
; some arrays
;======================
row_color:
.byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00
fine_sine:
.byte $00 ; 0.000000
.byte $19 ; 0.098017
.byte $31 ; 0.195090
.byte $4A ; 0.290285
.byte $61 ; 0.382683
.byte $78 ; 0.471397
.byte $8E ; 0.555570
.byte $A2 ; 0.634393
.byte $B5 ; 0.707107
.byte $C5 ; 0.773010
.byte $D4 ; 0.831470
.byte $E1 ; 0.881921
.byte $EC ; 0.923880
.byte $F4 ; 0.956940
.byte $FB ; 0.980785
.byte $FE ; 0.995185
.byte $FF ; 1.000000
.byte $FE ; 0.995185
.byte $FB ; 0.980785
.byte $F4 ; 0.956940
.byte $EC ; 0.923880
.byte $E1 ; 0.881921
.byte $D4 ; 0.831470
.byte $C5 ; 0.773010
.byte $B5 ; 0.707107
.byte $A2 ; 0.634393
.byte $8E ; 0.555570
.byte $78 ; 0.471397
.byte $61 ; 0.382683
.byte $4A ; 0.290285
.byte $31 ; 0.195090
.byte $19 ; 0.098017
.byte $00 ; 0.000000
.byte $E7 ; -0.098017
.byte $CF ; -0.195090
.byte $B6 ; -0.290285
.byte $9F ; -0.382683
.byte $88 ; -0.471397
.byte $72 ; -0.555570
.byte $5E ; -0.634393
.byte $4B ; -0.707107
.byte $3B ; -0.773010
.byte $2C ; -0.831470
.byte $1F ; -0.881921
.byte $14 ; -0.923880
.byte $0C ; -0.956940
.byte $05 ; -0.980785
.byte $02 ; -0.995185
.byte $00 ; -1.000000
.byte $02 ; -0.995185
.byte $05 ; -0.980785
.byte $0C ; -0.956940
.byte $14 ; -0.923880
.byte $1F ; -0.881921
.byte $2C ; -0.831470
.byte $3B ; -0.773010
.byte $4B ; -0.707107
.byte $5E ; -0.634393
.byte $72 ; -0.555570
.byte $88 ; -0.471397
.byte $9F ; -0.382683
.byte $B6 ; -0.290285
.byte $CF ; -0.195090
.byte $E7 ; -0.098017

View File

@ -176,8 +176,10 @@ COLOR_BOTH_MEDIUMBLUE EQU $66
COLOR_BOTH_LIGHTBLUE EQU $77 COLOR_BOTH_LIGHTBLUE EQU $77
COLOR_BOTH_BROWN EQU $88 COLOR_BOTH_BROWN EQU $88
COLOR_BOTH_ORANGE EQU $99 COLOR_BOTH_ORANGE EQU $99
COLOR_BOTH_PINK EQU $BB
COLOR_BOTH_LIGHTGREEN EQU $CC COLOR_BOTH_LIGHTGREEN EQU $CC
COLOR_BOTH_YELLOW EQU $DD COLOR_BOTH_YELLOW EQU $DD
COLOR_BOTH_AQUA EQU $EE
COLOR_BOTH_WHITE EQU $FF COLOR_BOTH_WHITE EQU $FF
AUX_BOTH_MEDIUMBLUE EQU $33 ; 0011 0011 AUX_BOTH_MEDIUMBLUE EQU $33 ; 0011 0011