Author Topic: xLIB 84C Edition  (Read 44762 times)

0 Members and 1 Guest are viewing this topic.

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB 84C Edition
« Reply #135 on: August 22, 2013, 02:54:15 am »
... base 37? Or do you mean 4-bits per tile? (So 1 hex character).

I thought I had asked everyone their thoughts and everyone seemed to agree on TIOS strings with hex chars @ 2 bytes per tile.

How would you dynamically change tiles (like remove obstacles etc) if your data is in FlashROM?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: xLIB 84C Edition
« Reply #136 on: August 22, 2013, 03:04:52 am »
Base 10 would be 0123456789
Base 16 would be 0123456789ABCDEF
Base 37 would be 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ and Theta.
Else maybe an higher base, where after Theta, we use Sin(, Cos(, Tan(, Ln(, log(, etc. (as long as those tokens are 1 bytes)

Also I think there was a misunderstood. People including me thought you meant an ASM hex string stored into compressed appvar (where each tile takes 1 bytes), not BASIC strings where one tile is made of two hex chars (due to not being squished with the AsmPrgm command) and thus, takes twice as much space. And I myself have never ever agreed with entirely string data, since I thought it was too massive (twice larger than ASM hex). Since you seemed relunctant about letting us dynamically change tiles such as obstacles in Flash ROM data, I thought it meant the map data would be stored in ASM and that for obstacles we would simply use a second copy of the map or hard-code some stuff.

Anyway, since it seems like you are going with the old school way of storing maps, I think we should stick to it now (Basic strings, that is). But still, if one map can have up to 256 different tiles, then each tile ends up taking two bytes, because they are made of two chars (eg 4B). Hence why I suggested Base 37 (I doubt someone would need more than 37 tiles in a single map). Not sure how hard it would make it to convert maps, though, plus it would not let the user use the entire sprite sheet at once x.x.

Anyway you haven't been very clear in general so far during explaining of xLIB features and how they work (no offense), so it might be best to wait until it's out then write a good readme explaining the syntax and what each arguments are, like the old xLIB readme did. Else there will just be too many misunderstoods and confusion (or maybe false hopes).
« Last Edit: August 22, 2013, 03:08:49 am by DJ Omnimaga »
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB 84C Edition
« Reply #137 on: August 22, 2013, 03:16:47 am »
Oh ok, I thought you meant base-37 as in a number system, not that you could have 37 characters to represent a tile.

The main reason why strings are used is because you can manipulate them with the TIOS. This means that you can do whatever you want with them and not need to wait around for someone to write an ASM lib just so you can copy data around. And people can make map editors in BASIC as well. Of note, the Zelda test map I used has 124 unique tiles, though I'm pretty sure you meant more than 37 tiles on 1 screen?

And 2-byte hex strings is still 4 times smaller than matrix elements, if that counts for anything :).

How about a 'squish/unsquish' function to encode the data in a string to 1-byte per tile?
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Re: xLIB 84C Edition
« Reply #138 on: August 24, 2013, 01:20:16 am »
Unsquish/squish would definitively be a great addition. :)
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: xLIB 84C Edition
« Reply #139 on: August 25, 2013, 03:24:44 pm »
Yes that should more than fine :)

EDIT - Also i added support for xLIB BG PIC's which are small res 80x60, 256 colour images that are scaled to fullscreen. These only take up 4800 bytes and could possibly be used for simple backgrounds, titlescreens or RPG battle backgrounds etc.

Here is a demo of a few strung together:



:D.
Rickroll!!!!!
Also, i guess you finished re-coding your lost code?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB 84C Edition
« Reply #140 on: August 25, 2013, 06:49:36 pm »
Yeah pretty much, plus i hope i have coded things a little better this time around anyway :).

I have also added a 'replaceTile' function which will search a tilemap string and replace the specified tileID with another. Can be useful for easy 2-frame tile animations.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: xLIB 84C Edition
« Reply #141 on: August 25, 2013, 06:53:30 pm »
wow, cool, does that also work that you'll say like, i only want the first 2 tiles replaced or is it always replacing all of 'em (to be honest, i can't find of a practical solution for my szenario right now >.<)

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB 84C Edition
« Reply #142 on: August 25, 2013, 06:56:19 pm »
At this stage its the whole map. You can still modify individual tiles with 'setTile' if you need to replace only specific tiles i guess.

I making a small proof of concept demo to try and demonstrate the features thus far ... (and to see if xLIB on the 84C is even feasible for games!).
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: xLIB 84C Edition
« Reply #143 on: August 25, 2013, 06:58:42 pm »
yaaaaay
* Sorunome expects DJ to make some epic RPG in 2 weeks using xlib

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: xLIB 84C Edition
« Reply #144 on: August 25, 2013, 07:55:52 pm »
I hope it's feasible for games lol. That said, having seen how fast the Zelda screens are, I bet it will. For an RPG, you need at least 2 FPS during character movement in a map engine, including collision detection and stuff
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: xLIB 84C Edition
« Reply #145 on: August 26, 2013, 01:06:33 am »
Yeah pretty much, plus i hope i have coded things a little better this time around anyway :).

I have also added a 'replaceTile' function which will search a tilemap string and replace the specified tileID with another. Can be useful for easy 2-frame tile animations.

That's pretty sweet. ^^

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB 84C Edition
« Reply #146 on: August 27, 2013, 08:13:32 pm »


Here is a small tilemap test. There is 8-directional movement (arrows+combos) and tile collision checking, the sprite is moving 8-pixels at a time.

The animated tiles are 2 frames and take advantage of the way xLIB uses GRAM, meaning that they dont require any extra processing once drawn.

Im working on making some more routines to speed things up if possible.

I apologize for the crappiness of the video and the fact that i did it on my phone just before leaving for work.

Here are some screenshots of the map:

"My world is Black & White. But if I blink fast enough, I see it in Grayscale."


Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: xLIB 84C Edition
« Reply #147 on: August 27, 2013, 09:30:39 pm »
Looks nice Tr1p! :D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55942
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: xLIB 84C Edition
« Reply #148 on: August 27, 2013, 11:03:50 pm »
Wow I didn't realize that animated tiles would be possible with the swapping between buffers, since I thought that the character would keep flickering or something when walking around. I assume that makes any HUD slower to display, right?

Anyway this really looks great and fast. *.* Btw how does the code look like? I am curious how large it is with this version of xLIB, especially collision detection.

Also nice sprites :D
Now active at https://discord.gg/cuZcfcF (CodeWalrus server)

Offline tr1p1ea

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 647
  • Rating: +110/-0
    • View Profile
Re: xLIB 84C Edition
« Reply #149 on: August 27, 2013, 11:12:24 pm »
Thanks, the sprites ive just been messing around with, but im pretty happy with the pine trees lol.

Yes to fully update a HUD you will be required to draw it twice.

The code for this demo, ive only been rushing through it so optimisation tips are welcome :).:

Code: [Select]
:real(0,1,0
:"TESTTILE
:real(5,0,0
:real(1,1,0,80
:real(1,1,1,8
:real(1,1,2,8
:real(1,1,3,8
:real(1,1,4,0
:real(1,1,5,0
:real(1,1,6,40
:real(3,0,4,5,6,9,0,0,19,14,1
:real(3,3,9,2,62,63,60,61
:real(3,0,4,5,6,9,0,0,19,14,0
:real(3,3,9,2,63,62,61,60
:Repeat real(2,0)=15
:If real(1,0,4)≠real(3,4,real(1,0,0),20) or real(1,0,5)≠real(3,4,real(1,0,1),15)
:Then
:real(1,1,4,real(3,4,real(1,0,0),20
:real(1,1,5,real(3,4,real(1,0,1),15
:real(3,0,4,5,6,9,0,0,19,14,1
:real(3,3,9,2,62,63,60,61
:real(3,0,4,5,6,9,0,0,19,14,1
:real(3,3,9,2,63,62,61,60
:End
:real(4,0,0,1,1,1,‾8real(1,0,4),‾8real(1,0,5),248,1,0,125
:real(4,0,2,3,1,1,‾8real(1,0,4),‾8real(1,0,5),1,0,0,real(3,1,2,3,6,9,0,0
:real(1,1,2,real(1,0,0
:real(1,1,3,real(1,0,1
:real(2,4,0,1,8,8,6,19,9,0,0,7,7
:End
:real(0,1,1

Here is a brief explanation of the code:

Code: [Select]
"Enable 160x240 mode
:real(0,1,0

"Load appvar tilePIC called "TESTTILE into memory slot 0
:"TESTTILE
:real(5,0,0

"Create player X,Y and tempX,tempY user variables
:real(1,1,0,80
:real(1,1,1,8
:real(1,1,2,8
:real(1,1,3,8

"Create map X,Y,MAPWIDTH user variables
:real(1,1,4,0
:real(1,1,5,0
:real(1,1,6,40

"Draw tilemap (uservar 4,5,6) to current GRAM buffer and switch GRAM (updateLCD)
:real(3,0,4,5,6,9,0,0,19,14,1

"Replace flower animated tiles in tilemap with 2nd frames
:real(3,3,9,2,62,63,60,61

"Draw tilemap (uservar 4,5,6) to current GRAM buffer (since we switched)
:real(3,0,4,5,6,9,0,0,19,14,0

"Replace flower animate tiles to original frames
:real(3,3,9,2,63,62,61,60

"Main loop (until player presses CLEAR
:Repeat real(2,0)=15

"Check if player X or Y is a different screen multiple than the current map X/Y (walked to a different area)
:If real(1,0,4)≠real(3,4,real(1,0,0),20) or real(1,0,5)≠real(3,4,real(1,0,1),15)
:Then
"If so then store new map X/Y and redraw map, replacing animated tiles as before
:real(1,1,4,real(3,4,real(1,0,0),20
:real(1,1,5,real(3,4,real(1,0,1),15
:real(3,0,4,5,6,9,0,0,19,14,1
:real(3,3,9,2,62,63,60,61
:real(3,0,4,5,6,9,0,0,19,14,1
:real(3,3,9,2,63,62,61,60
:End

"Draw main player sprite at player X/Y (uservar 0,1) and switch GRAM (updateLCD)
:real(4,0,0,1,1,1,‾8real(1,0,4),‾8real(1,0,5),248,1,0,125

"Redraw the tile at temp X/Y (uservar 2,3) that the previous player sprite was over to restore the tilemap
:real(4,0,2,3,1,1,‾8real(1,0,4),‾8real(1,0,5),1,0,0,real(3,1,2,3,6,9,0,0

"Copy current player X/Y to temp X/Y for use in next frame
:real(1,1,2,real(1,0,0
:real(1,1,3,real(1,0,1

"Get keypresses and move 8 pixels in X/Y, check that there are no collisions with any tiles >19 in the tilemap
:real(2,4,0,1,8,8,6,19,9,0,0,7,7

"Loop
:End

"Restore LCD to 320x240 mode
:real(0,1,1
« Last Edit: August 28, 2013, 12:45:16 am by tr1p1ea »
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."