Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Koala Screen Swapping
2010-08-19 14:16
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?
 
... 2 posts hidden. Click here to view all posts....
 
2010-08-19 16:14
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...
2010-08-19 16:18
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.
2010-08-19 16:29
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.
2010-08-19 17:50
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.

2010-08-22 03:52
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.
2010-08-22 09:57
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...
2010-08-22 11:18
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.
2010-08-24 20:08
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
2010-08-24 21:06
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)
2010-08-26 14:10
iAN CooG

Registered: May 2002
Posts: 3194
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
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Microshark/Damage(HUN)
morphfrog
cba
Manex/Anubis
Guests online: 149
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.062 sec.