|
Post by tiberiyltim on Feb 28, 2017 11:33:10 GMT -5
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 8, 2017 12:19:00 GMT -5
Definitely makes the Genesis look closer to a Super Nintendo. Awesome demo tiberiyltim!
Does anybody know if there are existing graphic tools and BEX code to do this? Seems like we're all re-inventing the wheel.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 8, 2017 12:37:52 GMT -5
My graphic program will support things like this, but keep in mind this would be difficult to pull off in a larger project. You have to really plan out your graphics once you start veering off the standard usage.
|
|
|
Post by tiberiyltim on Mar 8, 2017 18:41:31 GMT -5
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 9, 2017 8:51:21 GMT -5
And all of those are mainly done on single screens - you have to carefully plan to make it a viable solution in your program. I can use 6 palettes at once before using shadow mode, but it comes with restrictions.
|
|
|
Post by tiberiyltim on Mar 11, 2017 14:36:34 GMT -5
In BEX or ASM? How, if it not secret?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 11, 2017 23:37:43 GMT -5
Here's an example:
hBlank 111 On InterruptHBlank GoSub MyHBlank Enable InterruptHBlank On InterruptVBlank GoSub MyVBlank Enable InterruptVBlank While 1 Valt ' Sleep cannot be used while hblank is enabled Wend
MyVBlank: Palettes MyPal1,0,0,16 Return
MyHBlank: Palettes MyPal2,0,0,16 Return
MyPal1: DataInt $0888,$0000,$0000,$0000,$0000,$0000,$0000,$0000 DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
MyPal2: DataInt $0EEE,$0000,$0000,$0000,$0000,$0000,$0000,$0000 DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
Restrictions: - You can't use the palette you replace below the scanline - You can't use SLEEP commands while the HBLANK is on - Decreases VBLANK time
You should be able to figure out how to add more palettes from that. Also, this may leave little dots on the screen on the real hardware - I don't think there's any way of avoiding that.
|
|
|
Post by tiberiyltim on Mar 13, 2017 6:20:02 GMT -5
BEX error. Only SecondBASIC?
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 13, 2017 7:04:16 GMT -5
It should work. You probably need to change the enable vblank and hblank keywords to whatever BEX uses (I think it's: interrupt hblank and interrupt vblank, with spaces).
It does work fine in SecondBASIC, though, which if you have no plans for Sega CD or 32x games, I would recommend switching over as I've added some stuff to make things easier.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 14, 2017 9:46:14 GMT -5
Here's an updated example that works in BEX (and SecondBASIC):
hBlank 111 On HBlank GoSub MyHBlank Enable Interrupt HBlank On VBlank GoSub MyVBlank Enable Interrupt VBlank hb_val = 111 While 1 j = joypad(0) hb_val+=j.1-j.0 if hb_val = 0 then hb_val++ if hb_val = 224 then hb_val-- hblank hb_val Valt ' Sleep cannot be used while hblank is enabled Wend
MyVBlank: Palettes MyPal1,0,0,16 Return
MyHBlank: Palettes MyPal2,0,0,16 Return
MyPal1: DataInt $0888,$0000,$0000,$0000,$0000,$0000,$0000,$0000 DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
MyPal2: DataInt $0EEE,$0000,$0000,$0000,$0000,$0000,$0000,$0000 DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
I added in a joypad routine to adjust the hblank interval. Things to remember: - where the white color is is where the first palette ends and the replacement palette begins, so you can't use the replaced palette below that scan line (at least on the same palette index) - Sleep commands (sleep, sleep2) can't be used when the hblank is enabled. You can use Valt, WaitRaster, or Halt - HBlank time eats into the VBlank time, so your vblank time will be reduced slightly - HBlank 0 will disable the vblank entirely, and doesn't leave a lot of time for other code execution outside of the vblank and hblank. For example: a = addsprite(1,1) propsprite a,1,0 movesprite a,200,200
hBlank 0 On HBlank GoSub MyHBlank Enable Interrupt HBlank On VBlank GoSub MyVBlank Enable Interrupt VBlank x = 200 y = 200 While 1 j = joypad(0) x+=j.3-j.2 y+=j.1-j.0 movesprite a,x,y Wend
MyVBlank: Palettes MyPal1,0,0,16 Return
MyHBlank: Palettes MyPal2,0,0,16 Return
MyPal1: DataInt $0888,$0000,$0000,$0000,$0000,$0000,$0000,$0000 DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
MyPal2: DataInt $0EEE,$0000,$0000,$0000,$0000,$0000,$0000,$0000 DataInt $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
Since the hblank is set to 0, it triggers once every scanline. WaitRaster doesn't work at hblank 0 it seems (only a quick test was done), and if you move the sprite, it moves incredibly slow. Change the hblank to 5 or 25, and you'll need to use the Valt command in your program loop to make your sprite move at a normal speed, rather than way too fast. Some things you can do with hblank effects: - Stretch/distort background layers (Adventures of Batman & Robin and Rocket Knight Adventures do some excellent background raster tricks, unsure of Batman & Robin uses the horizontal interrupt, but Rocket Knight Adventures uses "hblank 0" when going through the castle where the fire shoots at you and the screen becomes wavy) - Add more palettes/colors - Those are the only 2 things I know that can be done using the hblank, but only one of which I know how to do.
|
|
|
Post by tiberiyltim on Mar 15, 2017 17:56:58 GMT -5
Cool! You have example 6 pal 64+ colors? For me does not work 6 pal.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 18, 2017 14:33:40 GMT -5
I don't think you'll be able to load 2 palettes during the hblank period, at least I couldn't. Here's an example of using 6 palettes and shadow mode, getting ~186 colors on screen at once. This won't work in BEX, though, only SecondBASIC. The reason for this is because you can't load palettes from a variable in BEX, as well as the use of the ShadowMode command. This eliminates an If..End If block during the blanking period, and turns on Shadow Mode easily instead of using an ASM code block Disable Screen Palettes pal4,1,0,16 Palettes pal5,2,0,16 Palettes pal6,3,0,16 LoadTiles Tiles,20,100 x2 = 0 x3 = 10 For x = 100 To 109 x3 = x2+10 For y = 0 To 3 For y2 = 0 To 63 Step 8 DrawTile x+Priority(0),x2,y+y2 DrawTile x+Priority(1),x2,y+4+y2 Next Next x2++ Next x2 = 0 n = 1 For x = 110 To 119 x3 = x2+10 For y = 0 To 3 If y > 1 Then n++ For y2 = 0 To 63 Step 8 DrawTile x+Priority(0)+Palette(1),x3,y+y2 DrawTile x+Priority(1)+Palette(1),x3,y+4+y2 DrawTile x+Priority(0)+Palette(2),x3+10,y+y2 DrawTile x+Priority(1)+Palette(2),x3+10,y+4+y2 DrawTile x+Priority(0)+Palette(3),x3+20,y+y2 DrawTile x+Priority(1)+Palette(3),x3+20,y+4+y2 Next Next x2++ Next ' 93 colors before shadow mode ShadowMode @On ' 186 colors with shadow mode Enable Screen
hBlank 75 pal& = LblPtr&(pal2) On hBlank GoSub effect On VBlank GoSub main WaitRaster 0 Enable hBlank Enable VBlank End
main: vcounter++ If vcounter = 100 Then ShadowMode @Off ElseIf vcounter = 200 Then ShadowMode @On vcounter = 0 End If Palettes pal1,0,0,16 Scroll Up, 1 Return
effect: Palettes pal&,0,0,16 pal_counter = pal_counter + 1 And 1 pal& = LblPtr&(pal3) If pal_counter Then pal& = LblPtr&(pal2) Return pal1: DataInt $0000,$0002,$0004,$0006,$0008,$000A,$000C,$000E DataInt $020E,$020C,$020A,$0208,$0206,$0204,$0202,$0200 pal2: DataInt $0E00,$0E02,$0E04,$0E06,$0E08,$0E0A,$0E0C,$0E0E DataInt $0C2E,$0C2C,$0C0A,$0C08,$0C06,$0C04,$0C02,$0C00 pal3: DataInt $00E0,$00E2,$00E4,$00E6,$00E8,$00EA,$00EC,$00EE DataInt $02EE,$02EC,$02EA,$02E8,$02E6,$02E4,$02E2,$02E0
pal4: DataInt $0EEE,$0EEC,$0EEA,$0EE8,$0EE6,$0EE4,$0EE2,$0EE0 DataInt $0CE0,$0CE2,$0CE4,$0CE6,$0CE8,$0CEA,$0CEC,$0CEE pal5: DataInt $0420,$0422,$0424,$0426,$0428,$042A,$042C,$042E DataInt $064E,$064C,$064A,$0648,$0646,$0644,$0642,$0640 pal6: DataInt $06E0,$06E2,$06E4,$06E6,$06E8,$06EA,$06EC,$06EE DataInt $08CE,$08CC,$08CA,$08C8,$08C6,$08C4,$08C2,$08C0
Tiles: DataFile hblanktiles.bnx, Bin
Here's a screenshot: Here's the source code + files: www.second-dimension.com/downloads/hblank_example.zip
|
|