Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some general questions from a novice ZX programmer
#1
Hi there!

Long story short, I coded some "games" in the 90s as a child with +3 Basic. Basically shit. I always wanted to code something decent and playable for my beloved speccy and well... better late than never!

I started reading, and reading, and reading a looot of information from a bunch of forums everytime I had a doubt and more or less I solved most things, but for a start, here is something that is bloking me from going on.

I managed to compile, with ZX Basic, a program where I can draw and print stuff into the screen, check keypresses, manage the charset and the udg's, use 4 sprites with fourspriter... and everything in a pretty reasonably-easy way, and also load compressed screens with aplib. The thing is that so far more or less everything is working, but there is a concept I don't understand. This is where I am stuck:

In my test program, I load a new entire charset with a set of tiles to draw a background, from a binary file, using aplib and included through asm code "incbin namefile.bin". I also add another compressed file for the udg graphics, and finally another one which stores the screen data and colors to create using the previously loaded charsets.

Followint instructions from other forums, with asm I prepared a space of memory following this example suggested by the god and lord nathan:

Code:
Sub mapContainer ()
mapdata:
   Asm
      mymap: defs 2400, 0
   End Asm
level1:
   Asm
         binary "level1c.bin"
   End Asm
level2:
   Asm
         binary "level2c.bin"
   End Asm
level3:
   Asm
         binary "level3c.bin"
   End Asm
End Sub

Which I changed to this:

Code:
Sub loadroom()
roombg:
   Asm
      roombg: defs 768, 0
   End Asm
roomtiles:
   Asm
      roomtiles: defs 768, 0
   End Asm
roomudg:
   Asm
      roombg: defs 168, 0
   End Asm
room01bg:
   Asm
         binary "room01.bgc"
   End Asm
room01tiles:
   Asm
         binary "room01.tic"
   End Asm
room01udg:
   Asm
         binary "room01.udc"
   End Asm
End Sub

That should load the 3 compressed files, but I am not sure where. Are those memory adresses? Arrays? That is confusing me. Applying the udg to the system was easy and worked, I just poked it to the specific adress. With the tiles though I had a problem, cause I had to add on the poke (0) + 256 (not sure why) and when I try that, it complains that @roomtiles is not an array. Finally, I solved it deleting the definition for @roomtiles in the asm part and defining it as an array with DIM roomtiles (787) etc.

Then the poking of the charset worked, but I had to change the (0) + 256 to (0) + 259 to get it right. Does it have something to do with being an array and having extra header info? I am really confused with arrays / memory adresses.

And finally, with all those loaded, I tried to load roombg, with my tile and attributes information, and to read it byte per byte... but I can't. Defining it in the asm code doesnt allow me to use it like roombg(15) to read the 15th byte, and defining it as an array makes it crash when I try to read it, giving incoherent values.

Which is the correct way to read byte per byte information of that memory adress? I tried peek, but dont know how to do it well, I tried value = peek 15 + @roombg, for example, but I also failed.

Everything is working great, in general, but this problem got me stuck.

Also, I would like to know where in the memory I am loading stuff and how much memory I have free... cause in the future, for sure, I will need to use banking switching if I want to load like 50 rooms :lol:

Well, thanks for everything! I will wait to see if I can understand exactly how to use this Smile
Reply
#2
I solved most of that stuff already, thanks! Smile
Reply
#3
Cesc Wrote:I solved most of that stuff already, thanks! Smile

Well done!

Have a look at the tutorials: https://zxbasic.readthedocs.io/en/docs/tutorials/

And for the pac man clone, you can grab a copy of berksman and work through the code that it ended up being, as well as read the blog I wrote about it - quite a lot about things like UDG sets. You'd use character sets the same way. (Or possibly, use putchars to dump it to the screen directly from the font data?)
Reply
#4
Thanks for the answer!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)