Ecernosoft Posted June 9, 2022 Share Posted June 9, 2022 Ok, So, I just finished version 1 of my Atari 7800 sprite decompression system. Code is in the post below. Here's how it works: This code can be used in your game. Basically, each byte holds the color (0= transparent, 1, 2, or 3) and the width (0-63, but 0 is interpreted as 256) The format goes like this: 76543210 \ /\/ Length,Color Drawing starts in bottom left corner and ends in the top right corner. Unfortunately, this uses up a lot of RAM. Since it decompresses the graphics into RAM, this eats 2K of the 7800's 4K. You can change the DLL's to be smaller, but then you get less sprites on a line. =/ Code is below for those who wanna look at it. ? ; Atari 7800 sprite sample ; Written by Daniel Boris (danlb_2000@yahoo.com) ; Modified by Steven Hugg @8bitworkshop ; Assemble with DASM ; processor 6502 ; ************ Hardware Adresses *************************** INPTCTRL equ $01 ;Input control AUDC0 equ $15 ;Audio Control Channel 0 AUDC1 equ $16 ;Audio Control Channel 1 AUDF0 equ $17 ;Audio Frequency Channel 0 AUDF1 equ $18 ;Audio Frequency Channel 1 AUDV0 equ $19 ;Audio Volume Channel 0 AUDV1 equ $1A ;Audio Volume Channel 1 INPT0 equ $08 ;Paddle Control Input 0 INPT1 equ $09 ;Paddle Control Input 1 INPT2 equ $0A ;Paddle Control Input 2 INPT3 equ $0B ;Paddle Control Input 3 INPT4 equ $0C ;Player 0 Fire Button Input INPT5 equ $0D ;Player 1 Fire Button Input BACKGRND equ $20 ;Background Color P0C1 equ $21 ;Palette 0 - Color 1 P0C2 equ $22 ;Palette 0 - Color 2 P0C3 equ $23 ;Palette 0 - Color 3 WSYNC equ $24 ;Wait For Sync P1C1 equ $25 ;Palette 1 - Color 1 P1C2 equ $26 ;Palette 1 - Color 2 P1C3 equ $27 ;Palette 1 - Color 3 MSTAT equ $28 ;Maria Status P2C1 equ $29 ;Palette 2 - Color 1 P2C2 equ $2A ;Palette 2 - Color 2 P2C3 equ $2B ;Palette 2 - Color 3 DPPH equ $2C ;Display List List Pointer High P3C1 equ $2D ;Palette 3 - Color 1 P3C2 equ $2E ;Palette 3 - Color 2 P3C3 equ $2F ;Palette 3 - Color 3 DPPL equ $30 ;Display List List Pointer Low P4C1 equ $31 ;Palette 4 - Color 1 P4C2 equ $32 ;Palette 4 - Color 2 P4C3 equ $33 ;Palette 4 - Color 3 CHARBASE equ $34 ;Character Base Address P5C1 equ $35 ;Palette 5 - Color 1 P5C2 equ $36 ;Palette 5 - Color 2 P5C3 equ $37 ;Palette 5 - Color 3 OFFSET equ $38 ;Unused - Store zero here P6C1 equ $39 ;Palette 6 - Color 1 P6C2 equ $3A ;Palette 6 - Color 2 P6C3 equ $3B ;Palette 6 - Color 3 CTRL equ $3C ;Maria Control Register P7C1 equ $3D ;Palette 7 - Color 1 P7C2 equ $3E ;Palette 7 - Color 2 P7C3 equ $3F ;Palette 7 - Color 3 SWCHA equ $280 ;P0, P1 Joystick Directional Input SWCHB equ $282 ;Console Switches CTLSWA equ $281 ;I/O Control for SCHWA CTLSWB equ $283 ;I/O Control for SCHWB ;| ;|| ;||| ;|||| ;||||| ;|||||| ;||||||| ;|||||||| ;76543210 SAVE SEG.U data ;******* Vairables ******************************** org $40 A ds.b 1 B ds.b 1 C ds.b 1 D ds.b 1 E ds.b 1 F ds.b 1 G ds.w 1 H ds.w 1 I ds.w 1 J ds.b 1 K ds.b 1 X ds.b 1 Y ds.b 1 temp ds.b 1 temp2 ds.b 1 org $80 DLLdata org $1800 GFXMEM org $2000; RAM SPR1data ds.b 64; graphics org $2100 SPR2data ds.b 64; Graphics org $25C0; End of DLs, $340 bytes free (384+64 bytes, or about 448 bytes) ;********************************************************** SEG code org $4000 ;Start of code START sei ;Disable interrupts cld ;Clear decimal mode ;******** Atari recommended startup procedure lda #$00 sta INPTCTRL ;Lock into 7800 mode lda #%11111111 sta CTRL ;Disable DMA lda #$00 sta OFFSET sta INPTCTRL ldx #$FF ;Reset stack pointer txs ;************** Clear zero page and hardware ****** ldx #$40 lda #$00 crloop1 sta $00,x ;Clear zero page sta $100,x ;Clear page 1 inx bne crloop1 ldy #$00 ;Clear Ram crloop2 sta $1800,y sta $1900,y sta $1a00,y sta $1b00,y sta $1c00,y sta $1d00,y sta $1e00,y sta $1f00,y sta $2200,y sta $2300,y sta $2400,y sta $2500,y sta $2600,y sta $2700,y iny bne crloop2 ldx #$00 crloop5 ;Clear 2100-213F sta $2100,x inx cpx #$40 bne crloop5 ;************* Build DLL ******************* ; 20 blank lines mainloop jsr Makesprite jsr MakeDLL lda #%01010000 sta CTRL jmp TEST jmp mainloop ;Loop\ TEST lda #>Graphics sta G+1 lda #<Graphics sta G lda #$19 sta K lda #$FF sta J lda #$ sta F jsr DRAW jsr Doit jmp Forever DataPacket inc G lda G bne Noinc2 inc G+1 Noinc2 lda (G),y sta D inc G lda G bne step1 inc G+1 step1 ldy #0 lda (G),y sta A step1.1 lda A and #%11000000 sta (H),y inc H+1 lda H+1 cmp #$20 bne Continue3 lda #$18 sta H+1 lda H adc #$07 sta H and #%11111000 cmp #$30 bne Continue3 lda H sbc #$2F sta H Continue3 lsr A lsr A lda A bne nofetch2 inc G lda (G),y sta A lda G bne nofetch2 inc G+1 nofetch2 dec D lda D beq Step1 DRAW lda #$18 sta H+1 lda #$80 sta E lda #%11000000 sta F Step1 ldy #0 lda (G),y sta temp and #%00000011 tax lda WRBITS,x sta E lda temp lsr lsr tax Step2 lda E and F ora (H),y sta (H),y inc H+1 lda H+1 cmp #$20 bne Continue lda #$18 sta H+1 lda H adc #$07 sta H and #%11111000 cmp #$30 bne Continue lda H sbc #$30 sta H lsr F lsr F lda F bne Continue lda #%11000000 sta F inc H lda H and #%00001000 cmp #$08 beq DONE Continue dex bne Step2 inc G lda G bne Continue2 inc G+1 Continue2 jmp Step1 DONE rts NMI RTI IRQ RTI Forever jmp Forever WRBITS byte #%00000000 byte #%01010101 byte #%10101010 byte #%11111111 ;Pointers to the DLs DLPOINTH .byte $22,$22,$22,$22,$23,$23,$23,$23,$24,$24,$24,$24,#$25,#$25,#$25,#$25,#$25,#$25,#$25,#$25,#$25,#$25,#$25,#$25 DLPOINTL .byte $00,$40,$80,$C0,$00,$40,$80,$C0,$00,$40,$80,$C0,#$00,#$10,#$20,#$30,#$40,#$50,#$60,#$70,#$80,#$90,#$A0,#$B0 Fronts hex 28589305843945FABCDAFCB2958923F475BA Backs MakeDLL Doit ldy #$18 ldx #0 Dort lda #$47 sta $80,x inx lda DLPOINTH,y sta $80,x inx lda DLPOINTL,y sta $80,x inx dey bne Dort rts Makesprite lda #$80 sta DPPL lda #$00 sta DPPH lda #$0F sta P0C1 lda #$0A sta P0C2 lda #$04 sta P0C3 lda #$00 sta $2500 lda #$08 sta $2510 lda #$10 sta $2520 lda #$18 sta $2530 lda #$20 sta $2540 lda #$28 sta $2550 lda #%01000000 sta $2501 sta $2511 sta $2521 sta $2531 sta $2541 sta $2551 lda #$18 sta $2502 lda #$18 sta $2512 sta $2522 sta $2532 sta $2542 sta $2552 lda #%00011000 sta $2503 sta $2513 sta $2523 sta $2533 sta $2543 sta $2553 lda #%00000000 sta $2504 sta $2514 sta $2524 sta $2534 sta $2544 sta $2554 lda #%01010000 sta CTRL lda #$18 sta CHARBASE ldy #$40 TEST2 tya sta $2000,y dey bne TEST2 rts TEST1; Format: ;76543210 ;|||||||| ;||||||color of pixels ;# of times to repeat pixel byte #%00000111 ;************** Graphic Data ***************************** ;set org and fill character org $8000,0 Graphics; 100000-000111=011000 byte #%00001000 byte #%00110101 byte #%10001000 byte #%00000101 byte #%00101111 byte #%00001101 byte #%10000000 byte #%00011001 byte #%00001011 byte #%00100101 byte #%01111100 byte #%00000101 byte #%00110011 byte #%00010001 byte #%01111100 byte #%01000101 byte #%01111100 byte #%00000101 byte #%00011011 byte #%00101001 byte #%01111100 byte #%00000101 byte #%00001011 byte #%00111001 byte #%01111100 byte #%00000101 byte #%00011011 byte #%00101001 byte #%01111100 byte #%01000101 byte #%01111100 byte #%00000101 byte #%00110011 byte #%00010001 byte #%01111100 byte #%00011001 byte #%00001011 byte #%00100101 byte #%01111100 byte #%00000101 byte #%00011011 byte #%00101001 byte #%01111100 byte #%00000111 byte #%01000001 byte #%01111100 byte #%00000101 byte #%00001011 byte #%00111001 byte #%01111100 byte #%01000101 byte #%01111100 byte #%00000101 byte #%00110111 byte #%00001101 byte #%01111100 byte #%00100101 byte #%00001111 byte #%00010101 byte #%01111100 byte #%00011101 byte #%00010011 byte #%00011001 byte #%01111100 byte #%00000101 byte #%00110111 byte #%00001101 byte #%01111100 byte #%01000101 byte #%01111100 byte #%00000101 byte #%00101011 byte #%00011001 byte #%01111100 byte #%00000101 byte #%00001011 byte #%00001001 byte #%00001011 byte #%00001001 byte #%00001011 byte #%00011001 byte #%01111100 byte #%01000101 byte #%01111100 byte #%00000101 byte #%00100011 byte #%00100001 byte #%01111100 byte #%00010101 byte #%00001011 byte #%00001001 byte #%00001011 byte #%00011001 byte #%01111100 byte #%00000101 byte #%00100011 byte #%00100001 byte #%01111100 byte #%01000101 byte #%01111100 byte #%00100001 byte #%00001011 byte #%00011101 byte #%01111100 byte #%00000101 byte #%00100111 byte #%00011101 byte #%01111100 byte #%00100001 byte #%00001011 byte #%00011101 byte #%01111100 byte #%00000101 byte #%00001011 byte #%00111001 byte #%10000000 byte #%00111101 ;************** Cart reset vector ************************** org $fff8 .byte $FF ;Region verification .byte $87 ;ROM start $4000 .word #NMI .word #START .word #IRQ Quote Link to comment Share on other sites More sharing options...
Ecernosoft Posted June 9, 2022 Author Share Posted June 9, 2022 This is only version 1. Version 2 will have more modes and support for data packets. Quote Link to comment Share on other sites More sharing options...
Ecernosoft Posted June 9, 2022 Author Share Posted June 9, 2022 Well, a data packet being traditional graphics data, with a terminator or set length, just it will be laid out vertically like this: 76543210 \ /\ /\ / L[] | | L __[] | L ____[] L ______[] (Of course there will be no offset) Quote Link to comment Share on other sites More sharing options...
Ecernosoft Posted June 9, 2022 Author Share Posted June 9, 2022 Sorry, here's an example of the example of the above code: The maximum size is 128 8*8 characters, or a canvas of 128*64 at 2bpp or 256*64 at 1bpp. The way I've set it up is 64*64 at 2bpp. Quote Link to comment Share on other sites More sharing options...
Ecernosoft Posted June 9, 2022 Author Share Posted June 9, 2022 Actually, my bad. This example is 32*40. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.