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 > Show Koala Pic
2014-11-09 19:57
Ejner

Registered: Oct 2012
Posts: 43
Show Koala Pic

I'm sure noone here has any problems with showing a simple Koala picture, but I came across this piece of code on codebase64.org and wondered why this had to be done so complicated...?

http://codebase64.org/doku.php?id=base:calculate_vic_settings_f..

In TurboAssembler it's pretty simple to calculate the VIC settings, see my example below. Isn't something similar possible with KickAssembler? Just wondering...

Example in TurboAssembler:

;---------------------------------------
;        Show Koala
;---------------------------------------
koala    = $6000
screen   = $5c00
;---------------------------------------
bank     = koala/$4000

         *= $1000

         lda #$3b
         sta $d011
         lda #koala-($4000*bank)/1024
         ora #(screen-($4000*bank))/64
         sta $d018
         lda #$d8
         sta $d016
         lda $dd02
         ora #%00000011
         sta $dd02
         lda $dd00
         and #%11111100
         ora #3-bank
         sta $dd00

         ldx #0
copy     lda koala+$1f40,x
         sta screen,x
         lda koala+$2040,x
         sta screen+$0100,x
         lda koala+$2140,x
         sta screen+$0200,x
         lda koala+$2228,x
         sta screen+$02e8,x
         lda koala+$2328,x
         sta $d800,x
         lda koala+$2428,x
         sta $d900,x
         lda koala+$2528,x
         sta $da00,x
         lda koala+$2610,x
         sta $dae8,x
         inx
         bne copy
         lda koala+$2710
         sta $d021
         lsr a
         lsr a
         lsr a
         lsr a
         sta $d020

         lda #0
         cmp $0277     ;wait for key
         bne *-3

         lda $dd02
         ora #%00000011
         sta $dd02
         lda $dd00
         and #%11111100
         ora #%00000011
         sta $dd00
         lda #$1b
         sta $d011
         lda #$15
         sta $d018
         lda #$c8
         sta $d016

         jmp $9000
;---------------------------------------

Note: The result of "bank = koala/$4000" is an integer.
 
... 32 posts hidden. Click here to view all posts....
 
2015-02-22 21:09
soci

Registered: Sep 2003
Posts: 480
From the calculations above it might not be obvious but the same address lines are wired to the top and bottom nibble of $d018.

Bit 0 could have been used for finer font base address selection in ECM mode, unfortunately that's not how it was implemented.
=8192					bitmap = 8192
=1024					screen = 1024

					        .block
=$2000					bmpfont .var $0000 | bits(bitmap)
=$0400					screen  .var $0000 | bits(screen)

.0000	 a9 18		lda #$18	        lda #screen[10:14]..bmpfont[10:14]
.0002	 8d 18 d0	sta $d018	        sta $d018
.0005	 ad 00 dd	lda $dd00	        lda $dd00
					        and #~(screen[14:16] || [])
.0008	 09 03		ora #$03	        ora #(~screen)[14:16] || []
.000a	 8d 00 dd	sta $dd00	        sta $dd00
					        .cerror (screen ^ bmpfont)[14:16], "different bank?!"
					        .bend
2015-02-22 21:42
Ejner

Registered: Oct 2012
Posts: 43
Groepaz, soci:
Okay, I didn't know that "|" (ORA?) feature before. I learn something new all the time :-)

koala    = $6000
screen   = $5c00

         *= $1000

         lda #[[>screen & $3f] << 2] | [[>koala & $3f] >> 2]
         sta $d018
         lda $dd00
         and #%11111100
         ora #3-[>koala >> 6]
         sta $dd00
2015-02-23 06:54
Oswald

Registered: Apr 2002
Posts: 5094
soci, thats a neat idea, tho I cant think of a scenario where it would be useful :) maybe some demo effect with lots of prepped csets.
2015-02-23 07:30
Dr.j

Registered: Feb 2003
Posts: 277
Soci , hehe i don't like to kill a fly with RPG but
what do you mean
by:
$0000 | bits(bitmap) where is the bits function? or i miss something.
and later:
and #~(screen[14:16] || []) hehe for not a C coders
could you make a friendly explain ? (you can do it on
private if you prefer)
2015-02-23 08:14
Flavioweb

Registered: Nov 2011
Posts: 463
I think Soci is talking about 64tass:
http://tass64.sourceforge.net/
2015-02-23 10:18
Dr.j

Registered: Feb 2003
Posts: 277
oh Flavioweb ok. i am kickass person so i leave it aside
for now hehe
2015-02-23 19:35
soci

Registered: Sep 2003
Posts: 480
Too much late coding yesterday ;) It would go even more off topic if I'd go into details in this thread.

The code fragment was only a demonstration about constructing $d018 values without using divisions and shifts.

Normally I use some variant of this:
lda #((font >> 10) & $0f) | ((screen >> 6) & $f0)
sta $d018
lda $dd00
ora #3
eor #font >> 14
sta $dd00
Even if this version is wasting 2 bytes half the time for the $dd00 calculation.
2015-02-23 19:38
chatGPZ

Registered: Dec 2001
Posts: 11386
why not just store a fixed value to $dd00 though? i dare to say that "properly" ORing the value is very rarely needed - certainly almost never in the usual setup code at the start of your intro/demo/whatever :)
2015-02-23 20:13
soci

Registered: Sep 2003
Posts: 480
Not sure why. I just checked and even my one filers are mostly doing the masking, where there's no chance of loader interference.

It must be tradition then.

So I now declare trademark rights on the ora/eor version. It may only identify genuine Singular productions ;)
2015-02-23 20:23
chatGPZ

Registered: Dec 2001
Posts: 11386
i see this often, also with eg $01 or $d011 .... people must have learned it somewhere :)
Previous - 1 | 2 | 3 | 4 | 5 - 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
FunFun/Triangle
Darkflight
Guests online: 87
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 Webmasters
1 Slaygon  (9.6)
2 Perff  (9.6)
3 Sabbi  (9.5)
4 Morpheus  (9.4)
5 CreaMD  (9.1)

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