mode7: add scroller work

This commit is contained in:
Vince Weaver 2017-12-14 00:59:34 -05:00
parent 660066f593
commit f3bae510cf
9 changed files with 498 additions and 4 deletions

View File

@ -4,14 +4,18 @@ DOS33 = ../dos33fs-utils/dos33
PNG2GR = ../gr-utils/png2gr
PNG2RLE = ../gr-utils/png2rle
all: mode7.dsk
all: mode7.dsk scroller
$(DOS33):
cd ../dos33fs-utils && make
mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD
mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
SCROLL_DEMO
$(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_RAINBOW
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SCROLL_DEMO
###
@ -29,6 +33,28 @@ mode7_checkerboard.o: mode7.s checkerboard_lookup.s \
fast_multiply.s utils.s zp.inc sprites.inc
ca65 -o mode7_checkerboard.o mode7.s -D CHECKERBOARD_MAP=1 -l mode7.lst
clean:
rm -f *~ *.o MODE7 MODE7_ISLAND MODE7_CHECKERBOARD *.lst
MODE7_RAINBOW: mode7_rainbow.o
ld65 -o MODE7_RAINBOW mode7_rainbow.o -C ./apple2_1000.inc
mode7_rainbow.o: mode7.s rainbow_lookup.s \
fast_multiply.s utils.s zp.inc sprites.inc
ca65 -o mode7_rainbow.o mode7.s -D RAINBOW_MAP=1 -l mode7.lst
SCROLL_DEMO: scroll_demo.o
ld65 -o SCROLL_DEMO scroll_demo.o -C ./apple2_1000.inc
scroll_demo.o: scroll_demo.s \
deater_scroll.inc
ca65 -o scroll_demo.o scroll_demo.s -l scroll_demo.lst
scroller: scroller.o
$(CC) $(LFLAGS) -o scroller scroller.o
scroller.o: scroller.c
$(CC) $(CFLAGS) -c scroller.c
clean:
rm -f *~ *.o scroller \
MODE7 MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
SCROLL_DEMO *.lst

9
mode7/deater_scroll.inc Normal file
View File

@ -0,0 +1,9 @@
scroll_length: .byte 127
scroll_row1:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$20,$20,$00,$00,$00,$20,$20,$20,$20,$00,$00,$20,$20,$00,$00,$20,$20,$20,$00,$20,$20,$20,$20,$00,$20,$20,$20,$00,$00,$00,$00,$00,$00,$00,$40,$00,$00,$00,$40,$00,$00,$40,$40,$00,$00,$00,$40,$40,$40,$00,$00,$00,$00,$00,$00,$10,$00,$00,$10,$00,$10,$10,$10,$10,$00,$10,$10,$10,$00,$00,$10,$10,$10,$10,$00,$10,$10,$10,$00,$10,$10,$10,$00,$10,$10,$10,$00
scroll_row2:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$E6,$00,$06,$E0,$00,$E6,$00,$00,$00,$00,$E6,$00,$00,$E6,$00,$00,$E6,$00,$00,$E6,$00,$00,$00,$00,$E6,$00,$00,$E6,$00,$00,$00,$00,$00,$00,$DC,$00,$00,$00,$DC,$00,$DC,$00,$00,$DC,$00,$DC,$00,$00,$00,$00,$00,$00,$00,$00,$00,$B3,$00,$00,$B3,$00,$B3,$00,$00,$00,$00,$B3,$00,$00,$B3,$00,$B3,$00,$00,$00,$00,$03,$B3,$03,$00,$03,$B3,$03,$00,$03,$B3,$03,$00
scroll_row3:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$EF,$00,$00,$EF,$00,$EF,$0F,$0F,$00,$00,$EF,$0F,$0F,$EF,$00,$00,$EF,$00,$00,$EF,$0F,$0F,$00,$00,$EF,$0F,$0F,$E0,$00,$00,$00,$00,$00,$00,$DF,$00,$D0,$00,$DF,$00,$DF,$0F,$0F,$DF,$00,$00,$0F,$0F,$D0,$00,$00,$00,$00,$00,$00,$BF,$0F,$0F,$BF,$00,$BF,$0F,$0F,$00,$00,$BF,$0F,$0F,$B0,$00,$BF,$0F,$0F,$00,$00,$00,$0F,$00,$00,$00,$0F,$00,$00,$00,$0F,$00,$00
scroll_row4:
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$26,$20,$06,$00,$00,$26,$20,$20,$20,$00,$26,$00,$00,$26,$00,$00,$26,$00,$00,$26,$20,$20,$20,$00,$26,$00,$00,$26,$00,$00,$00,$00,$00,$00,$4C,$0C,$00,$0C,$4C,$00,$4C,$00,$00,$4C,$00,$40,$40,$40,$0C,$00,$00,$00,$00,$00,$00,$13,$00,$00,$13,$00,$13,$10,$10,$10,$00,$13,$00,$00,$13,$00,$13,$10,$10,$10,$00,$00,$13,$00,$00,$00,$13,$00,$00,$00,$13,$00,$00

15
mode7/demo_notes Normal file
View File

@ -0,0 +1,15 @@
Image, loading screen
Pre-programmed island flight, over water too.
Scroll in text on bottom?
Checkerboard spin with bouncing sphere.
Mockingboard music.
Credits.
Starfield, raster bars while credits spin letters in place
to each thing. Also white inverse background to make it look
like text is on graphics
Apple Logo for APPLE ][ FOREVER

Binary file not shown.

View File

@ -967,6 +967,8 @@ nomatch:
.include "island_lookup.s"
.elseif .def(CHECKERBOARD_MAP)
.include "checkerboard_lookup.s"
.elseif .def(RAINBOW_MAP)
.include "rainbow_lookup.s"
.endif
match:
@ -1064,6 +1066,8 @@ lookup_map:
.include "island_lookup.s"
.elseif .def(CHECKERBOARD_MAP)
.include "checkerboard_lookup.s"
.elseif .def(RAINBOW_MAP)
.include "rainbow_lookup.s"
.endif
rts ; 6

24
mode7/rainbow_lookup.s Normal file
View File

@ -0,0 +1,24 @@
;====================
; lookup_map
;====================
; finds value in space_x.i,space_y.i
; returns color in A
; CLOBBERS: A,Y
lda SPACEX_I ; 3
sta spacex_label+1 ; self modifying code, LAST_SPACEX_I ; 4
lda SPACEY_I ; 3
sta spacey_label+1 ; self modifying code, LAST_SPACEY_I ; 4
lda SPACEX_I
and #$f
sta TEMP
asl
asl
asl
asl
ora TEMP
eor SPACEY_I
sta map_color_label+1 ; self-modifying

70
mode7/scroll_demo.s Normal file
View File

@ -0,0 +1,70 @@
.include "zp.inc"
;================================
; Clear screen and setup graphics
;================================
jsr clear_screens ; clear top/bottom of page 0/1
jsr set_gr_page0
;===============
; Init Variables
;===============
lda #0
sta DISP_PAGE
scroll_loop:
ldx scroll_length
ldy #0
draw_loop:
lda scroll_row1,Y
sta $400,Y
lda scroll_row2,Y
sta $480,Y
lda scroll_row3,Y
sta $500,Y
lda scroll_row4,Y
sta $580,Y
iny
dex
bne draw_loop
;==================
; flip pages
;==================
; jsr page_flip ; 6
;==================
; loop forever
;==================
jmp scroll_loop ; 3
;===============================================
; External modules
;===============================================
.include "utils.s"
;===============================================
; Variables
;===============================================
.include "deater_scroll.inc"
; waste memory with a lookup table
; move this to the zeropage?
gr_offsets:
.word $400,$480,$500,$580,$600,$680,$700,$780
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
.word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0

346
mode7/scroller.c Normal file
View File

@ -0,0 +1,346 @@
/* Use grey2 to make RLE more efficient? */
#include <stdio.h>
#include <string.h>
static unsigned char font[256][9]={
{0,0,0,0,0,0,0,0,0}, // 0
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, // 8
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, // 16
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, // 24
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{5,0,0,0,0,0,0,0,0}, // 32 ' '
{4,
0x00,
0xe0, // ******
0xe0, // ******
0x40, // **
0x40, // **
0x00, //
0x40, // **
0x40, // **
},
{0,0,0,0,0,0,0,0,0}, // 34
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, // 40
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, // 48
/*
** ** ** **** ** ** ****** **** ****** ** ****
** ** **** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ****** **** **** ** ** ****
** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** **
** ****** ****** **** ** **** ** ** ** **
*/
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, // 56
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}, //64
{5,
0x00,
0x60, // ****
0x90, // ** **
0x90, // ** **
0xf0, // ********
0x90, // ** **
0x90, // ** **
0x90, // ** **
},
{5,
0x00,
0xe0, // ******
0x90, // ** **
0x90, // ** **
0xe0, // ******
0x90, // ** **
0x90, // ** **
0xe0, // ******
},
{5,
0x00,
0x70, // ******
0x80, // **
0x80, // **
0x80, // **
0x80, // **
0x80, // **
0x70, // ******
},
{5,
0x00,
0xc0, // ****
0xa0, // ** **
0x90, // ** **
0x90, // ** **
0x90, // ** **
0xa0, // ** **
0xc0, // ****
},
{5,
0x00,
0xf0, // ********
0x80, // **
0x80, // **
0xe0, // ******
0x80, // **
0x80, // **
0xf0, // ********
},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
/*
********
**
**
******
**
**
**
****
**
**
** ****
** **
** **
****
*/
{5,
0x00,
0x90, // ** **
0x90, // ** **
0x90, // ** **
0xf0, // ********
0x90, // ** **
0x90, // ** **
0x90, // ** **
},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
/*
****** **** ** ** ** ** ** ** ** **** ******
** ** ** ** ** **** **** **** ** ** ** ** **
** ** ** ** ** ** ** ** **** ** ** ** ** **
** ** **** ** ** ** ** **** ** ** ******
** ** ** ** ** ** ** ** **** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** **
****** **** ** ** ******** ** ** ** ** **** **
*/
{0,0,0,0,0,0,0,0,0},
/*
****
** **
** **
** **
** **
** ****
** **
*/
{5,
0x00,
0xe0, // ******
0x90, // ** **
0x90, // ** **
0xe0, // ******
0x90, // ** **
0x90, // ** **
0x90, // ** **
},
{5,
0x00,
0x70, // ******
0x80, // **
0x80, // **
0x60, // ****
0x10, // **
0x10, // **
0xe0, // ******
},
{4,
0x00,
0xe0, // ******
0x40, // **
0x40, // **
0x40, // **
0x40, // **
0x40, // **
0x40, // **
},
{5,
0x00,
0x90, // ** **
0x90, // ** **
0x90, // ** **
0x90, // ** **
0x90, // ** **
0x90, // ** **
0x90, // ****
},
{5,
0x90, // ** **
0x90, // ** **
0x90, // ** **
0x90, // ** **
0x50, // ** **
0x50, // ** **
0x20, // **
},
{6,
0x00,
0x88, // ** **
0x88, // ** **
0x88, // ** **
0x88, // ** **
0xa8, // ** ** **
0xd8, // **** ****
0x88, // ** **
},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0},
/*
** ** ** ** **********
** ** ** ** **
** ** ** ** **
** ** **
** ** ** **
** ** ** **
** ** ** **********
*/
};
static int color_map[4][8]={
{0x2,0x2,0x6,0xe,0xf,0xe,0x6,0x2}, // Blue
{0x4,0x4,0xc,0xd,0xf,0xd,0xc,0x4}, // Green
{0x1,0x1,0x3,0xb,0xf,0xb,0x3,0x1}, // Red
{0x5,0x5,0x7,0xf,0xf,0xf,0x7,0x5}, // Grey
};
int main(int argc, char **argv) {
//char string[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
char string[]=" \001DEATER \002WAS \003HERE!!!";
int length=0,width=0,x,y,i;
int color,color1,color2;
int which_color=0;
unsigned char row[4][256];
for(i=0;i<strlen(string);i++) {
if (string[i]<5) { which_color=string[i]-1; continue;}
width=font[(int)string[i]][0];
for(x=0;x<width;x++) {
color=!!(font[(int)string[i]][1]&(0x80>>x));
color1=color?color_map[which_color][0]:0;
color=!!(font[(int)string[i]][2]&(0x80>>x));
color2=color?(color_map[which_color][1])<<4:0;
row[0][length]=color1|color2;
color=!!(font[(int)string[i]][3]&(0x80>>x));
color1=color?color_map[which_color][2]:0;
color=!!(font[(int)string[i]][4]&(0x80>>x));
color2=color?(color_map[which_color][3])<<4:0;
row[1][length]=color1|color2;
color=!!(font[(int)string[i]][5]&(0x80>>x));
color1=color?color_map[which_color][4]:0;
color=!!(font[(int)string[i]][6]&(0x80>>x));
color2=color?(color_map[which_color][5])<<4:0;
row[2][length]=color1|color2;
color=!!(font[(int)string[i]][7]&(0x80>>x));
color1=color?color_map[which_color][6]:0;
color=!!(font[(int)string[i]][8]&(0x80>>x));
color2=color?(color_map[which_color][7])<<4:0;
row[3][length]=color1|color2;
length++;
}
}
printf("scroll_length: .byte %d\n",length);
for(y=0;y<4;y++) {
printf("scroll_row%d:\n",y+1);
printf("\t.byte ");
for(x=0;x<length;x++) {
printf("$%02X",row[y][x]);
if (x!=length-1) printf(",");
}
printf("\n");
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB