Thursday 8 May 2014

A little bit of extraction (And example code)

8th May 2014

Well, well, well. Not much news on the Honey Bee front, as I am still waiting for some more updated graphics for it. Good news however is that I received some new game graphics for one of the screens. Bad news however - it was done in char pad as 1x1 tiles. However good news is that since the game consists of 1x1 tiles. The map screen size is one screen (40 chars across x 25 down).

I extracted the character set tile data, map data and attributes data and imported it into an ACME cross assembler source. Where single screens can be drawn through a map - then colour attributes get extracted according to the screen. I had some silly results at first, but after a third attempt - the overall result worked out quite nicely.

Now here's the source code which does this job ...

;--------------------------------------------------
;1x1 tile + colour Map extractor
;--------------------------------------------------

                            !to "extractor.prg",cbm
                            *=$2000 ;Import character set
                            !binary "hb_charset_v2.prg",,2
                          
                            *=$3000 ;Import map data (the screen matrix)
                            !binary "hb_map_v2.prg",,2
                            *=$3800 ;Import tiles data
                            !binary "hb_tiles_v2.prg",,2
                            *=$3c00 ;Import attributes (colour data)
                            !binary "hb_attribs_v2.prg",,2
                           
                            *=$c000 ;SYS49152 to execute

                            ldx #$00
loop0                   lda $3000,x ;Read map data from $3000
                            sta $0400,x ;Place on screen RAM $0400 - 256 chars
                            lda $3100,x ;Same again for next segment
                            sta $0500,x
                            lda $3200,x ;and again
                            sta $0600,x
                            lda $32e8,x ;and again
                            sta $06e8,x
                            inx
                            bne loop0
                         
                            ldx #$00
loop1                   ldy $0400,x ;Read the map on screen
                            lda $3c00,y ;Read the tile colour / attributes table
                            sta $d800,x ;Store to the C64 hardware char Colour RAM 256 times
                            ldy $0500,x ;Do the same with the next 256 chars
                            lda $3c00,y
                            sta $d900,x ;Store again ...
                            ldy $0600,x ;and again
                            lda $3c00,y
                            sta $da00,x
                            ldy $06e8,x ;and again
                            lda $3c00,y
                            sta $dae8,x
                                                    
                            inx
                            bne loop1
                          
                            lda #$18
                            sta $d018
                            sta $d016
                            lda #$0e
                            sta $d020
                            sta $d021
                            lda #$08
                            sta $d022
                            lda #$09
                            sta $d023
                            jmp *
                           
                           

                           

1 comment:

Josepzin said...

Nice graphics!

2023 at a glance

2024 is here, and 2023 has been a really quiet year on the production front due to everything that had gone back to normality. The year has ...