tfv: initial screen copy routine

This commit is contained in:
Vince Weaver 2017-05-12 14:29:21 -04:00
parent 225dc6f4cc
commit 4d846e778b
4 changed files with 114 additions and 13 deletions

View File

@ -605,23 +605,40 @@ short gr_addr_lookup[48]={
int grsim_put_sprite(unsigned char *sprite_data, int xpos, int ypos) {
int i,j,xsize,ysize;
unsigned char i;
unsigned char *ptr;
short address;
ptr=sprite_data;
xsize=*ptr;
x=*ptr;
ptr++;
ysize=*ptr;
ram[CV]=*ptr;
ptr++;
for(j=0;j<ysize;j++) {
address=gr_addr_lookup[(ypos+j)/2];
while(1) {
address=gr_addr_lookup[ypos/2];
address+=xpos;
for(i=0;i<xsize;i++) {
if (*ptr) ram[address]=*ptr;
for(i=0;i<x;i++) {
a=*ptr;
if (a==0) {
}
else if ((a&0xf0)==0) {
ram[address]&=0xf0;
ram[address]|=a;
}
else if ((a&0x0f)==0) {
ram[address]&=0x0f;
ram[address]|=a;
}
else {
ram[address]=a;
}
ptr++;
address++;
}
ypos++;
ram[CV]--;
if (ram[CV]==0) break;
}
return 0;

View File

@ -6,12 +6,12 @@ PNG2GR = ../gr-utils/png2gr
all: tfv.dsk
tfv.dsk: TITLE.GR TFV ED
$(DOS33) -y tfv.dsk BSAVE -a 0xc00 TFV
$(DOS33) -y tfv.dsk BSAVE -a 0x1000 TFV
$(DOS33) -y tfv.dsk BSAVE -a 0x400 TITLE.GR
$(DOS33) -y tfv.dsk BSAVE -a 0x900 ED
TFV: tfv.o
ld65 -o TFV tfv.o -C ./apple2_c00.inc
ld65 -o TFV tfv.o -C ./apple2_1000.inc
tfv.o: tfv.s title.inc
ca65 -o tfv.o tfv.s -l tfv.lst
@ -27,3 +27,4 @@ TITLE.GR: title.png
clean:
rm -f *~ TITLE.GR *.o *.lst ED

12
tfv/apple2_1000.inc Normal file
View File

@ -0,0 +1,12 @@
MEMORY {
ZP: start = $00, size = $1A, type = rw;
RAM: start = $1000, size = $8E00, file = %O;
}
SEGMENTS {
CODE: load = RAM, type = ro;
RODATA: load = RAM, type = ro;
DATA: load = RAM, type = rw;
BSS: load = RAM, type = bss, define = yes;
ZEROPAGE: load = ZP, type = zp;
}

View File

@ -40,9 +40,13 @@ MASK EQU $2E
COLOR EQU $30
FIRST EQU $F0
TEMP EQU $FA
RUN EQU $FA
TEMP2 EQU $FB
TEMP EQU $FA
RUN EQU $FA
TEMP2 EQU $FB
INL EQU $FC
INH EQU $FD
OUTL EQU $FE
OUTH EQU $FF
;=============================
; set low-res graphics, page 0
@ -55,6 +59,10 @@ TEMP2 EQU $FB
;=================
jsr CLRTOP
lda #$c
sta BASH
lda #$0
sta BASL ; load image off-screen 0xc00
lda #>(title_image)
sta GBASH
@ -62,14 +70,22 @@ TEMP2 EQU $FB
sta GBASL
jsr load_rle_gr
jsr gr_copy
lda #$4
sta BASH
lda #$0
sta BASL ; 0x400 is GR page 0
sta BASL ; restore to 0x400 (page 0)
; copy to 0x400 (page 0)
; Return to BASIC?
rts
;=====================================================================
;= ROUTINES
;=====================================================================
;=================
; load RLE image
;=================
@ -184,4 +200,59 @@ set_gr_page0:
bit GR ; set graphics
rts
;=========================================================
; gr_copy
;=========================================================
; for now copy 0xc00 to 0x400
; 2 + 8*38 + 4*80*23 + 4*120*26 + 13 = 20,159 = 20ms = 50Hz
gr_copy:
ldx #0 ; set y to zero ; 2
gr_copy_loop:
stx TEMP ; save y ; 3
txa ; move to A ; 2
asl ; mult by 2 ; 2
tay ; put into Y ; 2
lda gr_offsets,Y ; lookup low byte for line addr ; 5
sta OUTL ; out and in are the same ; 3
sta INL ; 3
lda gr_offsets+1,Y ; lookup high byte for line addr ; 5
sta OUTH ; 3
adc #$8 ; for now, fixed 0xc ; 2
sta INH ; 3
ldx TEMP ; restore y ; 3
ldy #0 ; set X counter to 0 ; 2
gr_copy_line:
lda (INL),Y ; load a byte ; 5
sta (OUTL),Y ; store a byte ; 6
iny ; increment pointer ; 2
cpx #$4 ; don't want to copy bottom 4*40 ; 2
bcs gr_copy_above4 ; 3
gr_copy_below4:
cpy #120 ; for early ones, copy 120 bytes ; 2
bne gr_copy_line ; 3
beq gr_copy_line_done ; 3
gr_copy_above4: ; for last four, just copy 80 bytes
cpy #80 ; 2
bne gr_copy_line ; 3
gr_copy_line_done:
inx ; increment y value ; 2
cpx #8 ; there are 8 of them ; 2
bne gr_copy_loop ; if not, loop ; 3
rts ; 6
; waste memory with a lookup table
; maybe faster than using GBASCALC?
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
.include "title.inc"