| | MisterMSK Account closed
Registered: Jul 2009 Posts: 37 |
Koala Screen Swapping
Hi All,
I saw a Max Headroom demo (if you could call it that) when I was a child. It was blue and basically moved his head from side to side. It look like three different pictures. Anyway, I was curious of how to change a picture on the fly. Do I just move the image in memory down to $2000 and re-run the view code or is there a different way I am missing? |
|
| | chatGPZ
Registered: Dec 2001 Posts: 11386 |
no, just place some pictures into ram, and use dd00 and d018 to switch between them |
| | STE'86
Registered: Jul 2009 Posts: 274 |
which as far as i remember only works for pics with exactly the same d800 colour ram?
swapping 3 random koala screens will result in major attribute clash.
hence the pics u saw were done with paintmagic which has total user control over each colour in a char square.
koala on the other hand selects its colour layout in each square by itself. hence it is much nicer to use to draw a full screen graphic but almost impossible to use for creating game graphics and graphics to convert to charset.
as i say this is from memory and it was a long time ago :)
Steve |
| | Mr. SID
Registered: Jan 2003 Posts: 424 |
I guess you mean this? Max Headroom [blue]
Look at the code, it's pretty simple. They basically flip through the VIC banks using a table:
.C:1059 A6 F7 LDX $F7
.C:105b E0 04 CPX #$04
.C:105d F0 EF BEQ $104E
.C:105f AD 00 DD LDA $DD00
.C:1062 29 FC AND #$FC
.C:1064 1D 7B 10 ORA $107B,X
.C:1067 8D 00 DD STA $DD00
No color ram changes are necessary, the pics don't have a lot of colors...
|
| | chatGPZ
Registered: Dec 2001 Posts: 11386 |
yes, the colorram must be either static, or you have to copy it.
that said, Max Headroom [blue] only uses 4 colors (so the colorram is not only static, but also the same value everywhere). and thats also the format used by paintmagic ( see http://unusedino.de/ec64/technical/aay/c64/gfxpmg0.htm ) - it uses one value for the entire colorram. |
| | Ed
Registered: May 2004 Posts: 173 |
I made a unfinished bitmap editor a long time ago featuring both a special sorter and also some features of "cleaning up garbage" and "force 3 color mode" to any bitmap picture... There have been more recent releases made for the pc featuring similar stuff for artists.
Just as implied the easiest would be to change $dd00 and $d018, but of course some times you also need to copy the bitmap picture to a new screen and/or copy the color-ram. |
| | JCB Account closed
Registered: Jun 2002 Posts: 241 |
And if you need to copy $d800 in for the new screen, be careful when you do it else you get a screen of colour for the wrong bitmap (or vice versa).
Just wait till the scan is past a certain point on the screen, start moving in new $d800 colours (if your code catches the raster, wait till a little lower down) then at some point before the screen starts to redraw (line 0 or whenever) change the $dd00 and $d018 pointers.
|
| | MisterMSK Account closed
Registered: Jul 2009 Posts: 37 |
I was trying to do something like this:
!to "movingpicture.prg",cbm
* = $0801
!byte $0b, $08, $00, $00, $9e, $32, $30, $36, $31, $00, $00, $00
PICTURE = $2000
BITMAP = PICTURE
VIDEO = PICTURE+$1f40
COLOR = PICTURE+$2328
BACKGROUND = PICTURE+$2710
* = $080d
sei
lda #$00
sta $d020 ; Border Color
lda BACKGROUND
sta $d021 ; Screen Color
; Transfer Video and Color
ldx #$00
.LOOPA
; Transfers video data
lda VIDEO,x
sta $0400,x
lda VIDEO+$100,x
sta $0500,x
lda VIDEO+$200,x
sta $0600,x
lda VIDEO+$2e8,x
sta $06e8,x
; Transfers color data
lda COLOR,x
sta $d800,x
lda COLOR+$100,x
sta $d900,x
lda COLOR+$200,x
sta $da00,x
lda COLOR+$2e8,x
sta $dae8,x
inx
bne .LOOPA
;
; Bitmap Mode On
;
lda #$3b
sta $d011
;
; MultiColor On
;
lda #$d8
sta $d016
;
; When bitmap adress is $2000
; Screen at $0400
; Value of $d018 is $18
;
lda #$18
sta $d018
ldx #20*1
lda #128
loop1 cmp $d012 ;check if the raster has reached line 128
bne loop1 ;no, so keep checking
loop2 cmp $d012 ;if it has you want to make sure you dont catch it more than once per frame
beq loop2 ;so wait till it isn't 0 any more
dex
bne loop1
; Transfer Video and Color
ldx #$00
.LOOPB
; Transfers video data
lda VIDEO+$3000,x
sta $0400,x
lda VIDEO+$100+$3000,x
sta $0500,x
lda VIDEO+$200+$3000,x
sta $0600,x
lda VIDEO+$2e8+$3000,x
sta $06e8,x
; Transfers color data
lda COLOR+$3000,x
sta $d800,x
lda COLOR+$100+$3000,x
sta $d900,x
lda COLOR+$200+$3000,x
sta $da00,x
lda COLOR+$2e8+$3000,x
sta $dae8,x
inx
bne .LOOPB
;
; Bitmap Mode On
;
lda #$3b
sta $d011
;
; MultiColor On
;
lda #$d8
sta $d016
;
; When bitmap adress is $2000
; Screen at $0400
; Value of $d018 is $18
;
lda #$28
sta $d018
ldx #20*1
lda #128
loop3 cmp $d012 ;check if the raster has reached line 128
bne loop3 ;no, so keep checking
loop4 cmp $d012 ;if it has you want to make sure you dont catch it more than once per frame
beq loop4 ;so wait till it isn't 0 any more
dex
bne loop3
jmp $080d
;File must be at same directory ofcourse
* = PICTURE
!binary "picturea.koa",,2
* = PICTURE+$3000
!binary "pictureb.koa",,2
However, I think I am having an issue with PICTURE+$3000 and the $D018 offset. |
| | Mr. SID
Registered: Jan 2003 Posts: 424 |
I don't think you've understood what we wrote above. You shouldn't need to copy VIDEO memory at all, only COLOR memory. You need to arrange your data in memory differently to allow that. Then all you have to do is switch $d018 and $dd00 appropriately... |
| | JCB Account closed
Registered: Jun 2002 Posts: 241 |
Yeah, imagine you put one bitmap with video ram $0400 and the bit data at $2000, then the next one at $4400 and $6000, then all you need to do to switch video/bitmap is change the bank as those addresses are the same offset from the start of each bank. Then all that needs actually copying in "realtime" is $d800 colour memory. |
| | MisterMSK Account closed
Registered: Jul 2009 Posts: 37 |
Hmmm.... JCB.. Thanks for the help so far. I actually had to take it up another notch for some odd reason $4400 interfered with a koala image I had down at $2000 (start). So I went with $8400 and $A000. The second picture displays but the top couple of lines are blocked.
!to "movingpicture.prg",cbm
* = $0801
!byte $0b, $08, $00, $00, $9e, $32, $30, $36, $31, $00, $00, $00
PICTUREA = $2000
BITMAPA = PICTUREA
VIDEOA = PICTUREA+$1f40
COLORA = PICTUREA+$2328
BACKGROUNDA = PICTUREA+$2710
PICTUREB = $A000
BITMAPB = PICTUREB
VIDEOB = PICTUREB+$1f40
COLORB = PICTUREB+$2328
BACKGROUNDB = PICTUREB+$2710
* = $080d
sei
lda #$00
sta $d020 ; Border Color
lda BACKGROUNDA
sta $d021 ; Screen Color
; Transfer Video and Color
ldx #$00
.LOOPA
; Transfers video data
lda VIDEOA,x
sta $0400,x
lda VIDEOA+$100,x
sta $0500,x
lda VIDEOA+$200,x
sta $0600,x
lda VIDEOA+$2e8,x
sta $06e8,x
; Transfers color data
lda COLORA,x
sta $d800,x
lda COLORA+$100,x
sta $d900,x
lda COLORA+$200,x
sta $da00,x
lda COLORA+$2e8,x
sta $dae8,x
inx
bne .LOOPA
;
; Bitmap Mode On
;
lda #$3b
sta $d011
;
; MultiColor On
;
lda #$d8
sta $d016
;
; When bitmap adress is $2000
; Screen at $0400
; Value of $d018 is $18
;
;lda #$18
lda #%00011000
sta $d018
ldx #20*1
lda #128
loop1 cmp $d012 ;check if the raster has reached line 128
bne loop1 ;no, so keep checking
loop2 cmp $d012 ;if it has you want to make sure you dont catch it more than once per frame
beq loop2 ;so wait till it isn't 0 any more
dex
bne loop1
sei
lda #$00
sta $d020 ; Border Color
lda BACKGROUNDB
sta $d021 ; Screen Color
; Transfer Video and Color
ldx #$00
.LOOPB
; Transfers video data
lda VIDEOB,x
sta $8400,x
lda VIDEOB+$100,x
sta $8500,x
lda VIDEOB+$200,x
sta $8600,x
lda VIDEOB+$2e8,x
sta $86e8,x
; Transfers color data
lda COLORB,x
sta $d800,x
lda COLORB+$100,x
sta $d900,x
lda COLORB+$200,x
sta $da00,x
lda COLORB+$2e8,x
sta $dae8,x
inx
bne .LOOPB
;
; Bitmap Mode On
;
lda #$3b
sta $d011
;
; MultiColor On
;
lda #$d8
sta $d016
;
; When bitmap adress is $A000
; Screen at $0400
; Value of $d018 is $18
;
lda #%00011000
sta $d018
lda $DD00
and #%11111100
ora #%00000001 ;<- your desired VIC bank value, see above
sta $DD00
ldx #20*1
lda #128
loop3 cmp $d012 ;check if the raster has reached line 128
bne loop3 ;no, so keep checking
loop4 cmp $d012 ;if it has you want to make sure you dont catch it more than once per frame
beq loop4 ;so wait till it isn't 0 any more
dex
bne loop3
lda $DD00
and #%11111100
ora #%00000011 ;<- your desired VIC bank value, see above
sta $DD00
jmp $080d
;File must be at same directory ofcourse
* = PICTUREA
!binary "picturea.koa",,2
* = PICTUREB
!binary "pictureb.koa",,2
|
| | JCB Account closed
Registered: Jun 2002 Posts: 241 |
Sorry about that, I'd not thought about just loading in raw koa files so they will overlap (or at least copying the screen ram to $4400 will overwrite the end of the other). I usually save everything out in parts so I can just shove things where I want them rather than 1 file.
Aaaanyway, to alleviate that problem just use $800 and $4800 for the two screen colour ram areas.
So you load one koa to $2000, the other to $6000, copy the koa+$1f40 to $800 and $4800 respectively, leave the bit data where it is and then the $d800 ram should be safe and not overwritten by anything..
After that you don't need to keep looping round and moving the $0800/$4800 ram just the $d800 from koa+$2328 and change the bank and you should be sorted.
So you should have code that looks like this...
Copy colour data for both pictures
Copy initial pictures $d800 ram
Set bitmap mode, bank, $d018 etc for 1st picture
Loop:
Wait on raster
copy other pictures $d800 ram
switch banks
Loop
*edit*
Doesn't really matter where you choose for the "screen" ram, as long as it's in the same bank, on an allowable boundary/start address etc. You can move it to just before the pixel data which makes it all a bit tidier (and one of the reasons I usually split things like koa files into their 3 sections)
|
| | iAN CooG
Registered: May 2002 Posts: 3195 |
Lincoln Memorial - Day & Nite
source posted for those who want to learn by example.
The pics are not in koala but for convenience already split in bitmap, screenmap and colormap, the splits have been obtained by saving vice snapshots while viewing the images and then using Vice Snapshot Grabber 4.0 |
|