Main Menu
Main Page
Forums
Recent changes
Random page
Help

Databases
GlitchDex
AttackDex
ItemDex
TypeDex
UnownDex
More

Major Glitches
Trainer escape glitch
Old man trick
Celebi trick
Select glitches (Japan)
SRAM glitch
CoolTrainer♀ corruption
LOL glitch
Rival LOL glitch
Super Glitch
ZZAZZ glitch
Pomeg corruption glitch (Glitzer Popping)
Tweaking
Elite Four door glitch (Japan)
Pokémon merge glitch
Pokémon cloning
Time Capsule exploit
Arbitrary code execution
Coin Case glitch
More

Other Glitch Categories
Glitches by generation
Glitches between two generations
Japan-only/language specific glitches
Music glitches
Natural glitches
Non-core series glitches
Non-Pokémon glitches
Officially acknowledged glitches
Recurring glitches
Dead glitches

References
Pokémon GameShark codes
The Big HEX List
GB programming
Curiosities
Debugging features
Easter eggs
Error traps
Glitch areas
Glitch myths
Non-glitch exploits
Placeholder texts
Pokémon glitch terminology
Unused content and prerelease information

Useful Tools
8F Helper
GBz80 to Items
Old man trick name generator
PATH (Prama's Advanced Tweaking Heaven)
Save file editors
Special stat/Pokémon converter
Trainer escape Trainer Pokémon finder

Affiliates
Legendary Star Blob 2 (Hakuda)
Pokémon Speedruns wiki
PRAMA Initiative
Become an affiliate!

Search Wiki

 

Search Forums

 

Author Topic: GBC-like Graphical Engine  (Read 1004 times)

0 Members and 1 Guest are viewing this topic.

ISSOtm

  • The French Lord of Laziness (and a huge The Legend Of Zelda fan)
  • Wiki Contributor
  • *
  • Offline Offline
  • Gender: Male
  • Pewter City (B)rocks !
    • View Profile
    • My Little Website
GBC-like Graphical Engine
« on: June 11, 2015, 08:53:09 am »
Hello everyone, ISSOtm here !

I am currently programming a game on my TI 84 Plus, and I wanted to display graphics in the same manner as a GBC.

I wrote some code, but it doesn't work that well...
Code: [Select]
; arguments :
; bc -> pointer to tile map (tile ID list)
; ix -> pointer to tile data (see tile structure)

GBClikeEngine:
ld de, appBackupScreen
ld hl, plotSScreen
ld a, 192  ; there are 384 tiles, but we are only going to draw half of them
push bc

drawEvenTiles:
push ix    ; we will later need to restore ix to load another tile pointer
push af

ld a, (bc) ; get the first tile's ID
push bc
add a, a   ; a contains the current tile's ID
add a, a   ; four bytes per tile
ld b, 0
ld c, a
add ix, bc ; now ix contains a pointer to the tile being drawn

drawEvenTile:  ; for some reason, evenly-numbered tiles must be drawn in one go, then all odd-numbered tiles will be.
ld b, 4    ; we are going to draw 4 lines
evenTileLoop:
ld a, (ix)
rld        ; load to main buffer. This is placed incorrectly, but "drawOddTiles" will rotate this into a correct position
and $F0
ld (de), a ; load to back-buffer
push bc    ; save counter
ld bc, 12
add hl, bc ; go 12 bytes later (one screen line)
ex de, hl
add hl, bc ; same
ex de, hl
inc ix     ; go to next byte of current tile data
pop bc     ; restore counter
djnz evenTileloop

pop bc
inc bc     ; we will draw the next tile
pop af
pop ix     ; restore the base tile pointer
dec a
jr nz, drawEvenTiles

pop bc
inc bc     ; we are going to draw the odd-numbered tiles, so add an offset of 1
ld de, L3
ld hl, L6
ld a, 192

drawOddTiles:
push ix    ; we will later need to restore ix to load another tile pointer
push af

ld a, (bc) ; get the first tile's ID
push bc
add a, a   ; a contains the current tile's ID
add a, a   ; four bytes per tile
ld b, 0
ld c, a
add ix, bc ; now ix contains a pointer to the tile being drawn

drawOddTile:
ld b, 4    ; we are going to draw 4 lines
oddTileLoop:
ld a, (ix)
rld        ; load to main buffer. This rotates the previously incorrectly-placed nibble into a correct position
and $F0
rrca
rrca
rrca
rrca
ld c, a
ld a, (de)
or c
ld (de), a ; load to back-buffer
push bc    ; save counter
ld bc, 12
add hl, bc ; go 12 bytes later (one screen line)
ex de, hl
add hl, bc ; same
ex de, hl
inc ix     ; go to next byte of current tile data
pop bc     ; restore counter
djnz oddTileloop

pop bc
inc bc     ; we will draw the next tile
pop af
pop ix     ; restore the base tile pointer
dec a
jr nz, drawOddTiles

ret
(appBackupScreen and plotSScreen are two RAM areas within the TI 84+)
The way it should be used is so :
Create some tile data, which is composed of four bytes per tile (one per line). The first byte goes to appBackupScreen, the second to plotSScreen.
Create some tile map, which is composed of 384 bytes (because the TI's screen is 96 * 64 pixels large, divided by 4 * 4 pixels per tile -> 384 tiles). Each byte holds the ID of the corresponding tile.
Call GBClikeEngine, with ix pointing to the tile data, and bc pointing to the tile map.

As I said, its objective is to reproduce the way the GBC screen works, on a TI 84 Plus (which as a B/W only display)

Could someone help me ? Thanks.
"THOU SHALL NOT PASS !!"  RIVAL's effect, Gandalf.

Proudly glitching Pokémon Red and Yellow on a Black & White GB, Pocket GB, GB Color, GBA SP and new 3DS.

My Twitter (beware, I'm French)
My YouTube (same warning)

Here is an online tool to build 8F setups : GBz80 to Items !

They see me layzin', they ha-tin'...
Heavy contributor of the global augmentation of entropy (my room's is too damn high !)