Subject: [stella] 13 chars C64-style From: Paul Slocum <paul-stella@xxxxxxxxxxxxxx> Date: Tue, 09 Dec 2003 01:06:56 -0600 |
;--------------------------------------------------------------------------- ; ; Generic 2600 Game ; ;--------------------------------------------------------------------------- processor 6502 include vcs.h ;--------------------------------------------------------------------------- ; Constants ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; RAM Variables ;--------------------------------------------------------------------------- frame equ $80 chara equ $81 charb equ $86 charc equ $8b chard equ $90 chare equ $95 charf equ $9a charg equ $9f temp equ $a4 temp2 equ $a5 line equ $a6 MAC TEXTCOPY ldx #{1}*2-1 lda text,x tay ldx #4 fontLoop{2} lda font,y and #%11110000 sta char{2},x iny dex bpl fontLoop{2} ldx #{1}*2 lda text,x tay ldx #4 fontLoop2{2} lda font,y and #%00001111 ora char{2},x sta char{2},x iny dex bpl fontLoop2{2} ENDM MAC TEXTDISP lda charg+{1} ;3 ; lda #255 sta ENAM0 ;3 lsr ;2 sta ENAM1 ;3 lsr ;2 ; sta WSYNC ;3 sta ENABL ;3 lda chara+{1} ;3 sta GRP0 ;3 lda charb+{1} ;3 sta.w GRP1 ;3 lda #$26 adc #{1}*2 tax stx COLUP0 stx COLUP1 lda charc+{1} ;3 sta GRP0 ;3 lda chard+{1} ;3 ldy chare+{1} ;3 stx COLUPF ldx charf+{1} ;3 sta GRP1 ;3 sty GRP0 ;3 stx GRP1 ;3 sta GRP0 ;3 lda #$20 sta COLUPF ENDM ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- org $F000 ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ;--------------------------------------------------------------------------- ; Start of Program ;--------------------------------------------------------------------------- ; Clear memory, locate character graphics positions and such, ; initialize key memory values, start GameLoop. ;------------------------------------------------------------- Start sei cld ldx #$FF txs lda #0 clear sta 0,x dex bne clear ;--------------------------------------------------------------------------- ; Initialize variables / registers ;--------------------------------------------------------------------------- lda #$48 sta COLUP0 lda #$99 sta COLUP1 lda #255 sta PF0 sta PF1 lda #0 sta PF2 lda #%00000101 sta WSYNC sta CTRLPF ; sta $2d ; sta $2d ; sta $2d sta GRP0 sta GRP1 lda #$03 ; set both players to 3 copies sta NUSIZ0 sta NUSIZ1 lda #$01 ; set vertical delay on for both players sta VDELP0 sta $2d sta RESM0 sta RESM1 sta VDELP1 sta RESBL sta RESP0 sta RESP1 lda #%11110000 sta HMP1 lda #%11100000 sta HMP0 lda #%10000000 sta HMBL lda #%10110000 sta HMM0 lda #%01010000 sta HMM1 sta WSYNC sta HMOVE ; Set playfield color lda #$06 sta COLUPF ;-------------------------------------------------------------------------- ; GameLoop ;-------------------------------------------------------------------------- GameLoop jsr VSync ;start vertical retrace inc frame ;count frame jsr VBlank ; spare time during screen blank jsr Picture ; draw one screen jsr overscan ; do overscan jmp GameLoop ;back to top text byte t,h,i,r,t,e,e,n,c,h,a,r,s ;-------------------------------------------------------------------------- ; VSync ;-------------------------------------------------------------------------- VSync lda #2 ;bit 1 needs to be 1 to start retrace sta VSYNC ;start retrace sta WSYNC ;wait a few lines sta WSYNC lda #44 ;prepare timer to exit blank period (44) sta TIM64T ;turn it on sta WSYNC ;wait one more sta VSYNC ;done with retrace, write 0 to bit 1 rts ; VSync ;-------------------------------------------------------------------------- ; VBlank ;-------------------------------------------------------------------------- ; Game Logic ;-------------------------------------------------------------------------- VBlank rts ; VBlank ;-------------------------------------------------------------------------- ; Overscan ;-------------------------------------------------------------------------- ; More Game Logic ;-------------------------------------------------------------------------- overscan sta WSYNC lda #$00 sta COLUBK lda #36 ; Use the timer to make sure overscan takes (34) sta TIM64T ; 30 scan lines. 29 scan lines * 76 = 2204 / 64 = 34.4 endOS lda INTIM ; We finished, but wait for timer bne endOS ; by looping till zero sta WSYNC ; End last scanline lda #$82 sta VBLANK lda #$02 sta VBLANK rts ; overscan ;-------------------------------------------------------------------------- ; Draw TV Pictures ;-------------------------------------------------------------------------- ; ;-------------------------------------------------------------------------- Picture pictureLoop lda INTIM ;check timer for end of VBLANK period bne pictureLoop ;loop until it reaches 0 sta WSYNC lda #$80 sta VBLANK ;end screen blank lda #8 sta line mainTextLoop ldx #0 lda text,x tay ldx #4 fontLoop1 lda font,y sta charg,x iny dex bpl fontLoop1 TEXTCOPY 1,a TEXTCOPY 2,b TEXTCOPY 3,c TEXTCOPY 4,d TEXTCOPY 5,e TEXTCOPY 6,f sta WSYNC ldx #8 dly dex bne dly nop sta $2d dec $2d lda #255 sta GRP0 sta GRP1 TEXTDISP 0 TEXTDISP 1 TEXTDISP 2 TEXTDISP 3 TEXTDISP 4 lda #0 sta GRP0 sta GRP1 sta GRP0 sta ENAM0 sta ENAM1 sta ENABL dec line beq quitTextLoop jmp mainTextLoop quitTextLoop ;------------------------------------------------------------------ ;------------------------------------------------------------------ endText lda #0 sta GRP0 sta GRP1 sta GRP0 sta GRP1 sta ENAM0 sta ENAM1 sta ENABL ldx #1 ScanLoop ;--------------------------------------------------------------------------- sta WSYNC dex bne ScanLoop rts ; Picture align 256 font a byte %10101010 byte %10101010 byte %11101110 byte %10101010 byte %01000100 b byte %11001100 byte %10101010 byte %11001100 byte %10101010 byte %11001100 c byte %01100110 byte %10001000 byte %10001000 byte %10001000 byte %01100110 d byte %11001100 byte %10101010 byte %10101010 byte %10101010 byte %11001100 e byte %11101110 byte %10001000 byte %11001100 byte %10001000 byte %11101110 f byte %10001000 byte %10001000 byte %11001100 byte %10001000 byte %11101110 g byte %01100110 byte %10101010 byte %11101110 byte %10001000 byte %01100110 h byte %10101010 byte %10101010 byte %11101110 byte %10101010 byte %10101010 i byte %01000100 byte %01000100 byte %01000100 byte %01000100 byte %01000100 j byte %10001000 byte %01000100 byte %01000100 byte %01000100 byte %11101110 k byte %10101010 byte %10101010 byte %11001100 byte %10101010 byte %10001000 l byte %11101110 byte %10001000 byte %10001000 byte %10001000 byte %10001000 m byte %10101010 byte %10101010 byte %10101010 byte %11101110 byte %10101010 n byte %10101010 byte %11101110 byte %11101110 byte %11101110 byte %10101010 o byte %01000100 byte %10101010 byte %10101010 byte %10101010 byte %01000100 p byte %10001000 byte %10001000 byte %11001100 byte %10101010 byte %11001100 q byte %01100110 byte %11101110 byte %10101010 byte %10101010 byte %01000100 r byte %10101010 byte %10101010 byte %11001100 byte %10101010 byte %11001100 s byte %11001100 byte %00100010 byte %01000100 byte %10001000 byte %01100110 t byte %01000100 byte %01000100 byte %01000100 byte %01000100 byte %11101110 u byte %11101110 byte %10101010 byte %10101010 byte %10101010 byte %10101010 v byte %01000100 byte %01000100 byte %10101010 byte %10101010 byte %10101010 w byte %10101010 byte %11101110 byte %10101010 byte %10101010 byte %10101010 x byte %10101010 byte %10101010 byte %01000100 byte %10101010 byte %10101010 y byte %01000100 byte %01000100 byte %01000100 byte %10101010 byte %10101010 z byte %11101110 byte %10001000 byte %01000100 byte %00100010 byte %11101110 ;--------------------------------------------------------------------------- ; Program Startup ;--------------------------------------------------------------------------- org $FFFC .word Start .word Start
Attachment:
13ch.bin
Description: Binary data
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] tia hue luminance, Adam Wozniak | Thread | [stella] 24 chars with a little fli, Christopher Tumber |
Re: [stella] tia hue luminance, Adam Wozniak | Date | Re: [stella] 13 chars C64-style, Thomas Jentzsch |
Month |