Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Chriszx/UNITRAX ! (Registered 2024-05-26) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > [gamedev] Reading level data problem
2005-10-03 18:43
BastetFurry

Registered: Jul 2005
Posts: 88
[gamedev] Reading level data problem

Hi Folks!

I try to code something in asm, and as i like them its going to be a simple RPG.
But now i have a little problem, how to read the map data?
I have this, hardcoded for now, testdungeon in my programm:
party: ;X first and then Y
!byte $01,$02

dungeon1: ;16x16 grid of map data
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$01,$01,$01,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$01,$00,$01,$00,$01,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$01,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$01,$01,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
!byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00

As i am used to do high level programming, i cant figure out how to get something from there with the party coordinates.
I hope somebody can give at least a hint how to get an address out of x and y.

2005-10-03 18:59
Oswald

Registered: Apr 2002
Posts: 5029
hi, just do this:

mul16

.word 0
.word 16
.word 32
.
.
.
.word 16*16

lda y
asl
tay
lda mul16,y
sta $fe
lda mul16+1,y
sta $ff

; read map data here:

ldy x
lda ($fe),y


(it is possible to do this faster, but for a general routine this is the way)
2005-10-03 19:27
JackAsser

Registered: Jun 2002
Posts: 1994
Don't forget to add base address of the map...

Basically address to read from = leveldata+x+y*16. And as Oswald mentioned y*16 can be looked up from a mul16 table easily.

But then you might wanna consider this: Imagine you already know what address you are on, say in the middle (16*8+8), then if you move left you simply decrease it, if you move right you increase it, if you move up you subtract 16 and if you move down you add 16, instead of always recalculating it everytime.
2005-10-03 21:05
Ben
Account closed

Registered: Feb 2003
Posts: 163
Hmm.. I would do this the simple way:

lda y
asl
asl
asl
asl
clc
adc x
tax
lda table,x
2005-10-03 21:05
BastetFurry

Registered: Jul 2005
Posts: 88
Thanks both of you, it works like a charm ^.^
I could even adapt it to draw chars to the screen for me.
2005-10-03 21:06
BastetFurry

Registered: Jul 2005
Posts: 88
Quote: Hmm.. I would do this the simple way:

lda y
asl
asl
asl
asl
clc
adc x
tax
lda table,x


If you could please explain that to me?
I understanded the first one, but that is a bit cryptic for me :-/
2005-10-03 21:06
Ben
Account closed

Registered: Feb 2003
Posts: 163
Quote: Thanks both of you, it works like a charm ^.^
I could even adapt it to draw chars to the screen for me.


I see we cross-posted.. Just ignore me then ;)
2005-10-03 21:10
Ben
Account closed

Registered: Feb 2003
Posts: 163
Quote: If you could please explain that to me?
I understanded the first one, but that is a bit cryptic for me :-/


lda y
asl
asl
asl
asl

would yield y*16 in the accumulator

clc
adc x

would yield y*16+x in the accumulator
and now use this as offset in your table :)

tax
lda table,x


This works as 16*16 = 256 obviously :)
If you start using larger tables you would indeed need to resort to Oswald's method or some other variations of my snippet ;)

2005-10-03 22:55
BastetFurry

Registered: Jul 2005
Posts: 88
This is it so far, i think not bad for the first real (somewhat) usefull ASM. (The other things where testing and "basic research" ;) )

http://fileanchor.com/4547-d

You are in the center und move around with Joy2.

Ill try to catch some sleep now, any suggestions are welcome.
(Dont disassemble or you will be shocked by my horrible code. I think i will better never attend a 4k ;) )
2005-10-07 17:05
Honesty

Registered: Jan 2003
Posts: 117
Nah... For coding counts in the end thaT it worx and do what it should do how i look like is equal to my opinion...

There are many ways leading to rome...

2005-10-08 12:15
Ben
Account closed

Registered: Feb 2003
Posts: 163
Quote: Nah... For coding counts in the end thaT it worx and do what it should do how i look like is equal to my opinion...

There are many ways leading to rome...



If the operational specifications of 'doing' also includes executing in the minimum number of cycles then these 5 cycles being won (under equal conditions) do make a difference clearly..
2005-10-09 07:30
BastetFurry

Registered: Jul 2005
Posts: 88
Hey, i am coding a game, not a demo ;)
Aaaand i got an idea of manipulating the charset. Ok, i have done it the cheapest way possible, made it with cuneinform, inserted it into the source at $2000 and told the VIC where to find it.

If you want to see.
--> http://fileanchor.com/5356-d (1683 byte -ZIP)

Dev is slow but steady.
Next stop is a messaging system using the last 5 lines on the screen or so.
After that i will include the PCs and then the first NPCs, with them a battle screen.

If anyone wants to give me some GFX, be my guest ^.^
2005-10-09 12:24
Ben
Account closed

Registered: Feb 2003
Posts: 163
Looks better already :)
What kind of game is this supposed to become?
2005-10-09 14:40
Laxity

Registered: Aug 2005
Posts: 459
"lda y"?... what compiler are you guys using? Shouldn't that be "tay"?
2005-10-09 15:14
Ben
Account closed

Registered: Feb 2003
Posts: 163
Quote: "lda y"?... what compiler are you guys using? Shouldn't that be "tay"?

Hehe :)

x and y are variables of some sort..
This pseudocode would obviously become

a)
"y lda #0"
with y the label, where you would need to "sta y+1".
This would compile to something like "sta $1001"

b)
"y .byte 0
[..]
lda y"
where you would need to "sta y", which would compile to something like
"1000 0
1001 lda $1001
"
and "sta $1000"

c)
"y = $d0
[..]
lda y"
where you would need to "sta y", which would compile to
"lda $d0" and "sta $d0"

et cetera.. et cetera..
2005-10-09 16:38
BastetFurry

Registered: Jul 2005
Posts: 88
Quote: Looks better already :)
What kind of game is this supposed to become?


A RPG of some sort
2005-10-09 17:04
Laxity

Registered: Aug 2005
Posts: 459
Quote: Hehe :)

x and y are variables of some sort..
This pseudocode would obviously become

a)
"y lda #0"
with y the label, where you would need to "sta y+1".
This would compile to something like "sta $1001"

b)
"y .byte 0
[..]
lda y"
where you would need to "sta y", which would compile to something like
"1000 0
1001 lda $1001
"
and "sta $1000"

c)
"y = $d0
[..]
lda y"
where you would need to "sta y", which would compile to
"lda $d0" and "sta $d0"

et cetera.. et cetera..


doh! Stupid me ;)
2005-10-10 13:20
White Flame

Registered: Sep 2002
Posts: 136
Using ORA instead of ADC lets you get rid of the CLC:

lda party+1 ;y
asl
asl
asl
asl
ora party ;x
tax
lda dungeon1,x

Then again, if your party 'x' and 'y' are guaranteed to be between 0 and 15, carry would be clear at that point regardless.
2005-10-10 14:08
Oswald

Registered: Apr 2002
Posts: 5029
gah, I shouldnt at first post into this topic, I knew all smartheads will show up and tell how it could be done 1 cycle faster or 1 byte shorter :)
2005-10-10 14:28
JackAsser

Registered: Jun 2002
Posts: 1994
@Oswald: Isn't that what C64 is all about? :D
2005-10-10 14:30
BastetFurry

Registered: Jul 2005
Posts: 88
@Oswald:
I find it funny, lets see when this cant be optimized any further.

@White Flame:
Cool, with this i can trow away the multiplication table for 16x16 maps.
BTW: In wich dimeonsions is that code working?
Can i easily switch to 32x32 with it?
2005-10-10 14:56
Ben
Account closed

Registered: Feb 2003
Posts: 163
Quote: @Oswald:
I find it funny, lets see when this cant be optimized any further.

@White Flame:
Cool, with this i can trow away the multiplication table for 16x16 maps.
BTW: In wich dimeonsions is that code working?
Can i easily switch to 32x32 with it?


@Bastet: RMFP.. Read my friggin post :) the 4 times asl is multiplying by 16 so go figure :)

@Oswald.. I did not want to go there either, but Honesty seduced me to :)
2005-10-12 22:26
BastetFurry

Registered: Jul 2005
Posts: 88
Messaging system: Done! (was easy)
Beginning of scripting engine: Done! (Not that easy ;) )

http://www.nachtkatzen.de/c64/dc.zip
(From my space as FileAnchor is down :-/ )
Now i need to find out a way to load data trough kernel (should be easy) and write a frigging map editor (PC-Based...). Hard mapmaking when working with !byte lines *g*
2005-10-13 14:57
Ben
Account closed

Registered: Feb 2003
Posts: 163

When do I get to kiss the princess?
2005-10-13 20:14
BastetFurry

Registered: Jul 2005
Posts: 88
You mean the generic story of rescuing the dragon, slaying the princess and saving the treasure?
Naa, i wont do this ;) It will me more like Morrowind but with a party this time.
You versus the evil Drow-god.
(Drows are Dark Elves)
2005-10-14 05:10
JackAsser

Registered: Jun 2002
Posts: 1994
Fascinating to see a port of Morrowind (highend 3D game for PC) converted to C64. :D Oh right!, you meant the gameplay and story right? Not the gfx? =D


(also, Drow stuff rules, I've always had a fetish on Drow amoury, weapons, spells etc. in RPGs, especially in the Eye of the Beholder series)
2005-10-14 23:55
BastetFurry

Registered: Jul 2005
Posts: 88
Gameplay, yes.
I wont steal the Elder Scroll storyline.
And if you donate a SCPU to me ill try my hands at some 3D. Unless that happens you all are stuck with old scool 8-bit console gfx. (Which is better in my opinion anyways *g* )
As said somewhere else, if someone wants to donate GFX or, better, some fantasy SID Tunes (Adventure, Battle and Shop) or some SID effects (Sword slashes, firing a bow or fireball, .... whatever happens to fit to fantasy) ill be happy and very thankfully for it.
RIght now i am working on a loading routine as i cant trow roughly 500 kbyte of mapdata in a onefiler ;)
(Not talking about savegames..........)
2005-10-15 08:16
drake
Account closed

Registered: Dec 2002
Posts: 207
the first elder scrolls. sigh(!)
that was the ultimate game for me for a long time.
and i always got lost somewhere in the game :-)

will this be a game with 16 disksides?
2005-10-15 10:25
BastetFurry

Registered: Jul 2005
Posts: 88
If you want to torture yourself playing this on 1541, then probelary yes, but i wont support that.
You will need some kind of Harddisk or a nice and shiney 1581. ;)

EDIT: If PTV can make a game for SuckerCPU i can make a game that wont run on 1541, right? ;)
2005-10-15 10:41
Nafcom

Registered: Apr 2002
Posts: 588
Quote: If you want to torture yourself playing this on 1541, then probelary yes, but i wont support that.
You will need some kind of Harddisk or a nice and shiney 1581. ;)

EDIT: If PTV can make a game for SuckerCPU i can make a game that wont run on 1541, right? ;)


A 1581 is fine for me! :)
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
Didi/Laxity
Sentinel/Excess/TREX
DeeKay/Crest
iAN CooG/HVSC
Knut Clausen/SHAPE/F..
DjS/Silicon Ltd
Asthor/Exlusive ON
syntaxerror
Guests online: 89
Top Demos
1 Next Level  (9.8)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Aliens in Wonderland  (9.7)
5 Coma Light 13  (9.7)
6 Edge of Disgrace  (9.6)
7 No Bounds  (9.6)
8 Comaland 100%  (9.6)
9 Uncensored  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Happy Birthday Dr.J  (9.8)
2 Layers  (9.6)
3 It's More Fun to Com..  (9.6)
4 Cubic Dream  (9.6)
5 Party Elk 2  (9.6)
6 Copper Booze  (9.6)
7 TRSAC, Gabber & Pebe..  (9.5)
8 Rainbow Connection  (9.5)
9 Dawnfall V1.1  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Nostalgia  (9.4)
2 Oxyron  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 SHAPE  (9.3)
Top Logo Graphicians
1 Sander  (9.9)
2 Facet  (9.6)
3 Mermaid  (9.4)
4 Pal  (9.4)
5 Shine  (9.3)

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