Author Topic: FX-Unit Yuki: The Henshin Engine for TurboGrafx-16/PC Engine  (Read 27105 times)

Black Tiger

  • Hero Member
  • *****
  • Posts: 11241
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #360 on: April 25, 2017, 12:54:44 PM »
I didn't realize that palette variants couldn't be done in HuC and had been pushing them to save on space.

I take it that fade-to-black type stuff is done using custom mapper routines?
http://www.superpcenginegrafx.net/forum

Active and drama free PC Engine forum

Gredler

  • Guest
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #361 on: April 25, 2017, 01:18:35 PM »
I didn't realize that palette variants couldn't be done in HuC and had been pushing them to save on space.

I take it that fade-to-black type stuff is done using custom mapper routines?

I may be speaking out of place here, but I assume it's related to multiple instances of the same tile - I think you can shift a tile's palette but all instances of that tile update at that time in the current HuC mapper code.


That's how the lights flicker on the background of level one in your game ;)

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #362 on: April 25, 2017, 04:06:11 PM »
Well, take this scene, for example...



There is supposed to be a complex sky here. However, the number of unique tiles in this area required me to remove it to fit in the normal background details. Here, it wasn't such a big deal to remove it, as there is still plenty of detail. But these are two different areas... the volcano section and the part with the 45 degree slopes are one area, this tree section is the next area. There should be still space in the tree section to add in the sky and clouds, but even as such, it's going to require a lot of additional unique tiles to fill in said level of detail. We do what we can to make things as detailed as is feasible, but when you're dealing with a system with only one background plane and have graphics clearly intended for more than one, you have to do a lot of additional work to make things go together properly. A single variation change on something as seemingly simple as a tree branch will cost you numerous additional tiles, and that's for just one variation... the sky has numerous potential variations in it, meaning that the tile count will multiply.

I understand, but as you said, the sky detail isn't missed there because there are loads of other background details in there, but if I may suggest something:
https://youtu.be/P6mCDkcO8cg?t=9m44s
^Like what New Adventure Island does here, just one 32 x 16 sprite of a cloud repeated here and there passing by behind the BG layer, that alone would already go a long way! It doesn't have to be that detailed, it just has to be 'something'...

But you don't have to listen to me, if you can't put anything in there then don't worry, it's fine ^^';

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #363 on: April 25, 2017, 06:42:35 PM »
I'm not exactly clear on what you guys are talking about, but...

Quote
Is it possible to use the same tile multiple times with different palettes?
Yes. Provided you have extra palettes to use.

Quote
You'd have to have your own mapper routine for that.
What mapper routine?

Quote
I think you can shift a tile's palette but all instances of that tile update at that time in the current HuC mapper code.
Yes, you can shift a tile's palette as well. All instances of the tile using that palette will change.
But that has nothing to do with HuC. That's how the vdc/vce operate.
....................................................................................
The BAT determines which tiles are displayed, and which palette they use.
So, for example, if you have the tile data at 0x2000 in vram, then a BAT entry of 0x1200 and a BAT entry of 0x2200 will use the same tile data, but different palettes. (The high 4 bits of the BAT entry specify the palette, the low 12 bits are the vram address / 16 )
You could then shift/change palette 2 without affecting the display of the 0x1200 entries.

I can see that there would be problems if you are loading the BAT to do scrolling and such, and it would definately be a pain to generate a background where two tiles have different palettes, but that doesn't mean it can't be done.
I think the real problem is they're running out of VRam for tile/sprite data.

Gredler

  • Guest
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #364 on: April 25, 2017, 07:34:10 PM »
I think the real problem is they're running out of VRam for tile/sprite data.

Thanks for the information, and I think this is the thing Rover was talking about. I for some reason thought there could be a screen full of tiles at any given time, and the blue area was a blank tile - but could be switched to the same tile that gradates in color from the bottom row to the top.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #365 on: April 26, 2017, 09:26:16 AM »
Not with HuC. You'd have to have your own mapper routine for that.

You've actually managed to implement all of the lovely stuff that you guys have done within the limits of HuC's tile and map library functions???  :shock:

Congratulations!  :clap:

A quick look at the library code suggests that that's 8x8 or 16x16 tiles (1 or 4 VDC hardware-tiles), max 256 tiles per map, max 256x256 map size, with palette defined by the tile number.

Is that right, or have I missed something?

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #366 on: April 26, 2017, 10:50:32 AM »
At one point, I was playing around with what you could do with tiles, just to see what was possible...

Assuming you know where the tile is in the BAT, you can read it's value via  n=vram[addr], and re-write it via vram[addr] = n. All in HuC.
So, if you mask off the upper 4 bits, then or in an adjusted palette #, it is possible.
Probably slow, but possible.
I haven't played with the HuC map functions, though. I haven't needed to. I basically set up the standard screen layout, load 2 screens to start, and then as things need to scroll fill in the new edges.

Gredler

  • Guest
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #367 on: April 26, 2017, 11:29:02 AM »

As always, please excuse my ignorance but I love hearing and clarifying this stuff.

8x8 or 16x16 tiles (1 or 4 VDC hardware-tiles),
This for sure is what I've been told and stuck to

max 256 tiles per map,
Is this the conflict with vram limitations? My next question could answer this one, but is this why there could be no room in the vram for a single tile additional in the screenies of question?

max 256x256 map size,
Does that mean 4096 is the max size for a mappy (256x256 16x16 tiles)?

with palette defined by the tile number.
So to my previous question, there's not a practical/fast way to flood a screen with a single tile, then change each row's color to create a gradient for a background?

Assuming you know where the tile is in the BAT, you can read it's value via  n=vram[addr], and re-write it via vram[addr] = n. All in HuC.
So, if you mask off the upper 4 bits, then or in an adjusted palette #, it is possible.
Probably slow, but possible.
Slow in time to code, or slow in how long it takes to display each frame?

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #368 on: April 26, 2017, 01:59:35 PM »
Quote
Quote
max 256 tiles per map...
Is this the conflict with vram limitations?
Probably not. It's probably due using a register as an offset to load the tiles.

Quote
Does that mean 4096 is the max size for a mappy
Using the HuC functions, probably. Note that 4096 tiles works out to 8K, and I'm not sure if the map functions support crossing pages....

Quote
there's not a practical/fast way to flood a screen with a single tile, then change each row's color to create a gradient for a background?
Practical, yes. Fast, not so much, unless you go to assembler.
...
Using a temp array to hold 1 row of tile data (dependant on the BAT size), you can use
vram_read() to read in a row, then fix the tile palette, write it back (vram_load(), iirc), and bump the address as needed. Loop for however many rows you need.

Just for the record: If you do it in assembler, you can take advantage of the auto-increment
mode of the vdc, and loop using X and Y. It's actually pretty fast to do the transfer, if things are
set up right.
...
Quote
Slow in time to code, or slow in how long it takes to display each frame?

Neither. Slow in time to fill in the BAT. Assuming you don't change the BAT, its a one-shot cost.
It's slow if you have to replace BAT values for scrolling, for example. The vram[] array stuff sets the read/write address every time, which negates any advantage gained from auto-increment mode :(
And we know HuC is slow on array accesses (because of the address calculation it has to do)

If you're really interested in doing this, check out the vram_read() / vram_load() functions (macros?). If you can spare the space for a temp buffer, you can fill a row from vram quickly, make your changes, and then re-write it quickly. Not hard to code at all.

But much quicker in assembler....

fill_vram() { / #asm / ....asembler code here ... / #endasm / }
we do things like that quite a bit; the function is callable from HuC, and runs at assembler speed (because it is assembly)

Keep in mind, though, this is assuming you are not using the HuC map functions, and will handle scrolling / re-writing the BAT yourself.

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #369 on: April 26, 2017, 02:55:29 PM »
So to my previous question, there's not a practical/fast way to flood a screen with a single tile, then change each row's color to create a gradient for a background?
I don't know if it's possible in HuC (I assume not), but in Magical Chase on Stage 1 they actually use scanline interrupts to change the solid background colour that goes behind everything in order to do a gradient, I've seen this being done in a few other games too, such as Asuka 120% Maxima Burning Fest in the dialogue screens where they change not only the solid BG colour but at least one of the palettes as well, (see the dialogue box near the bottom of the screen) and on Metamor Jupiter on that rotating tube background...
So yeah, you don't even need tiles to make a gradient in the sky, and if you did it that way the gradient wouldn't move together with the BG if it moved vertically, thus making a bit of parallax, but again, I don't know if HuC supports that...

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #370 on: April 26, 2017, 03:42:39 PM »
Assuming you know where the tile is in the BAT, you can read it's value via  n=vram[addr], and re-write it via vram[addr] = n. All in HuC.

It's a cool programming-metaphor, but it's actually (slightly) slower than the dedicated __fastcall functions that do the same thing, so FYI, I removed those vram[] arrays in the new HuC.


But much quicker in assembler....

fill_vram() { / #asm / ....asembler code here ... / #endasm / }
we do things like that quite a bit; the function is callable from HuC, and runs at assembler speed (because it is assembly)

Keep in mind, though, this is assuming you are not using the HuC map functions, and will handle scrolling / re-writing the BAT yourself.

Yep ... HuC is OK, as long as you're using the built-in library functions (written in assembly-language)  to do stuff ... but anything that it doesn't directly support is only going to run fast if you write your own optimized assembly language code for it.

Arkhan and TheOldMan have spent a long time learning just what does, and does not, need that kind of optimization in their games.  :clap:


As always, please excuse my ignorance but I love hearing and clarifying this stuff.

There's never anything wrong with asking questions!  :wink:


Quote from: elmer
max 256 tiles per map,
Is this the conflict with vram limitations? My next question could answer this one, but is this why there could be no room in the vram for a single tile additional in the screenies of question?

It's because the map in HuC uses a byte to store the tile number, rather than a 16-bit word/int.

That halves the amount of space needed for the map ... but it means that you're limited to 256 tiles.

And there's no room in the map to store a palette number either, so the palette number to use is looked-up from the tile number, instead of just being a part of the map-data.

It's a design trade-off ... reducing the size of stuff in RAM/HuCard, but causing a limitation in the graphics.

Consider ... 256 16x16 tiles take up 32KB of VRAM ... that probably seemed like a sensible limit when HuC was written.

OTOH ... 256 8x8 tiles only take up 8KB of VRAM, and severely limits the graphic-quality.

Design trade-offs are like that ... there's no one-size-fits-all solution!  :(


max 256x256 map size,
Does that mean 4096 is the max size for a mappy (256x256 16x16 tiles)?

As-in 4096x4096 pixels maximum map size? Well yep ... kind-of.

Except that HuC also has a secondary mechanism for using multiple 256-tile-x-256-tile maps within a 16384-tile-x-16384-tile area.

But that's getting really complicated, and I suspect that you'd be better-off writing your own map functions if you needed large maps like that.


The low-RAM (i.e. HuCard) 4th-gen stuff that I've done used the tile/block/map design.

There the map is still byte-per-entry, but the byte is a block number (0..255).

Each block is then a 4-word 2x2 tile entry, allowing up to 1024 tiles, and allowing each tile in each block to specify its own palette.

Still limited ... but it allows for the reuse of tiles with different palettes, and it allows for more tiles (i.e. better graphics).

But again, it has its own design trade-offs.

BTW ... if you get sneaky, you can use certain map codes to trigger the loading/swapping of the block definitions to work around the 256-block limit.  :wink:


When you have more RAM, like on the PCE CD, you can use 16-bits per entry in the map, with up to 4096 tiles, and full palette usage ... and then sectorize and compress everything and just decompress the sectors that are close to the player.

That gives you the greatest flexibility ... but it comes at the cost of complex art-tools and runtime code.


with palette defined by the tile number.
So to my previous question, there's not a practical/fast way to flood a screen with a single tile, then change each row's color to create a gradient for a background?

I can't think of a *simple* way, within the design of the HuC library, particularly if you're scrolling the screen.

If you drop down into ASM, you could do a nasty hack ... but if you're writing in ASM, then you'd just redesign the map functions and avoid the limit altogether.


So yeah, you don't even need tiles to make a gradient in the sky, and if you did it that way the gradient wouldn't move together with the BG if it moved vertically, thus making a bit of parallax, but again, I don't know if HuC supports that...

Good point!  :clap:

That might be the sane way to do something with little cost, but it might need custom assembly-language code and, if so, could easily cause lots of problems with HuC's existing split-screen hblank-interrupt code.

IMHO, it would be a risky thing to try to add to Henshin Engine at this point.
« Last Edit: April 26, 2017, 03:44:13 PM by elmer »

Gredler

  • Guest
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #371 on: April 26, 2017, 07:15:47 PM »
Thanks so much for the break down Elmer and Old Man, your concise and clear explanations register somewhat.  I appreciate you guys taking the time to elaborate; even if some of the specifics are Greek to me I think I understand the ideas.

Even with solid color bg's the art shines through and Henshaw continues to look great, keep up the good work fellers!

nodtveidt

  • Guest
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #372 on: April 27, 2017, 06:13:56 PM »
So whilst swimming about, Yuki gets the point.



And yeah elmer, the visuals have all been done within the limits of stock HuC 3.21 thus far.

TheOldMan, as far as I know, HuC's tile mapper thingo assigns each tile to a specific palette when you load everything in, and there's no direct way to monkey with it without haxoring the mapper code, which is beyond my meager code orangutan skills.

EDIT: Interesting observation as soon as I posted that pic... I forgot to fill in the appropriate edge tiles along the barrier. Dangit. :lol:
« Last Edit: April 27, 2017, 06:16:50 PM by The Old Rover »

Michirin9801

  • Hero Member
  • *****
  • Posts: 589
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #373 on: April 27, 2017, 06:28:10 PM »
So whilst swimming about, Yuki gets the point.



Looks pretty good ^^
(Please tell me those tiles are dynamic)

So yeah, you don't even need tiles to make a gradient in the sky, and if you did it that way the gradient wouldn't move together with the BG if it moved vertically, thus making a bit of parallax, but again, I don't know if HuC supports that...


Good point!  :clap:

That might be the sane way to do something with little cost, but it might need custom assembly-language code and, if so, could easily cause lots of problems with HuC's existing split-screen hblank-interrupt code.

IMHO, it would be a risky thing to try to add to Henshin Engine at this point.


I'm not saying they should do it in Henshin Engine but...
I wonder if it's possible for a future version of HuC to support this feature ;3

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Henshin Engine Game for TurboGrafx-16/PC Engine
« Reply #374 on: April 28, 2017, 06:57:02 AM »
You can use the same tile with a different palette if you do it ahead of time.

See: Atlantean.

Same tile, different (darker) palette was used for the back row of buildings.   Once it's loaded however, you're sort of f*cked with the built ins, IIRC.  Or there was a way to do it but it was sort of goony.     

I honestly haven't touched much PCE stuff in a few years because of MSX, outside of noodling with music, and talking to old man about random stupid ideas and how-tos.

I don't want to 6502 my brain in the middle of z80ing a game.   lol
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.