From 4d846e778bd43f6950de8f0be89aa65f7ec5fb29 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 12 May 2017 14:29:21 -0400 Subject: [PATCH] tfv: initial screen copy routine --- gr-sim/gr-sim.c | 31 ++++++++++++++---- tfv/Makefile | 5 +-- tfv/apple2_1000.inc | 12 +++++++ tfv/tfv.s | 79 ++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 114 insertions(+), 13 deletions(-) create mode 100644 tfv/apple2_1000.inc diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index 82bb5462..61abdbfb 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -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(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"