Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Plotting tiles

Reply to topic
Author Message
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Plotting tiles
Post Posted: Thu Jan 10, 2019 4:39 pm
So what I want to do is make a wall using tile $001E down the length of the screen in my Game Gear game I decided to make. But I'm having trouble. I can get one tile where I want the start of the wall to be vertically, but that's it. Here is my code so far:

SCREEN_2:
       ld hl,$38EE
       call vrampr
       ld hl,screen2tile
       ld bc,1*32         
       call vramwr   

draw_on_screen:
       ld a,(wallbuild)
       add a,1
       ld (wallbuild),a

       ld a,(wallbuild)
       cp 16
       jp z,Screen_2_end

       jp draw_on_screen

Screen_2_end:
       ret

screen2tile      .dw $001E

Any attempts to add 32 to $38EE leave me with no result I want. The wallbuild variable is a timer to make sure it ends the wall where I want it to end (at the bottom of the screen) So, how do I do this?
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14688
  • Location: London
Reply with quote
Post Posted: Thu Jan 10, 2019 5:39 pm
You appear to only be calling vramwr once. You need to add 32 to move down one row.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Post Posted: Thu Jan 10, 2019 6:06 pm
That's what I was having the problem with. I couldn't add 64 to $38EE. The next block I want at $392E, and $392e-$38ee=64. So I need to add 64 to $38EE, but I can't for some reason.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Post Posted: Thu Jan 10, 2019 6:11 pm
Found out my problem.
Remove call vrampr from the loop.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Post Posted: Thu Jan 10, 2019 6:25 pm
But now I need to figure out how to make it not make the tile afterwards for the first one. I have a sky and a ground, and it puts the sky tiles in front of the blocks on the ground.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14688
  • Location: London
Reply with quote
Post Posted: Thu Jan 10, 2019 8:32 pm
Your descriptions are confusing.
  View user's profile Send private message Visit poster's website
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Post Posted: Thu Jan 10, 2019 9:00 pm
Sorry. What I need is a better way to do this:

SCREEN_2:
       ld hl,$38EE
       call this_is_tedious
       ld hl,$392E
       call this_is_tedious
       ld hl,$396E
       call this_is_tedious
       ld hl,$39AE
       call this_is_tedious
       ld hl,$39EE
       call this_is_tedious
       ld hl,$3A2E
       call this_is_tedious
       ld hl,$3A6E
       call this_is_tedious
       ld hl,$3AAE
       call this_is_tedious
       ld hl,$3AEE
       call this_is_tedious
       ld hl,$3B2E
       call this_is_tedious
       ld hl,$3B6E
       call this_is_tedious
       ld hl,$3BAE
       call this_is_tedious
       ld hl,$3BEE
       call this_is_tedious
       ld hl,$3C2E
       call this_is_tedious
       ld hl,$3C6E
       call this_is_tedious
       ld hl,$3CAE
       call this_is_tedious
       ld hl,$3CEE
       call this_is_tedious
       ld hl,$3D2E
       call this_is_tedious
       ret

this_is_tedious:
       call vrampr
       ld hl,screen2tile
       ld bc,1*2
       call vramwr
       ret

screen2tile      .dw $001E
  View user's profile Send private message Visit poster's website
  • Joined: 24 Sep 2018
  • Posts: 66
Reply with quote
Post Posted: Fri Jan 11, 2019 3:01 am
There are two solutions: get your assembler to write the code statically, if it can, or write a quick loop.

I've no idea which assembler you're using so can't help with the former. Look in its manual for its macros section.

Otherwise, suboptimally:


    ld hl, $38ee
    ld a, 18
your_loop:
    push af
    push hl
    call this_is_tedious
    pop hl
    ld bc, 64
    add hl, bc
    pop af
    dec a
    jr nz, your_loop

this_is_tedious:
       call vrampr
       ld hl,screen2tile
       ld bc,1*2
       call vramwr
       ret


... and possibly improve on that by finding a smarter way to preserve HL and A than constantly pushing and popping them. In fact, whether you need to push and pop AF at all depends on what you do in vrampr and vramwr, but it's a safe guess.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3763
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Jan 11, 2019 9:14 am
all you need is a 16-bit variable in RAM to hold the VRAM address you want to write to, then you do:

[a] initialize that var to $38EE
[b] load the value to HL
[c] out HL to VDP control so that it sets the address
[d] set DE to 64
[e] add DE to HL
[f] save HL to that var we created
[g] now load screen2tile to HL
[h] out HL to VDP data so that it sets the tile
[i] if you're not done (you may keep a counter in B register), go back to [b]
  View user's profile Send private message Visit poster's website
  • Joined: 14 Aug 2000
  • Posts: 740
  • Location: Adelaide, Australia
Reply with quote
Plotting tiles
Post Posted: Fri Jan 11, 2019 2:45 pm
My thinking is similar to TomHarte above.

SCREEN_2:
       ld b,18
       ld hl,$38EE
       ld de,64
TEDIOUS_LOOP:
       call this_is_tedious
       add hl,de
       djnz TEDIOUS_LOOP
       ret

this_is_tedious:
       push af
       push bc
       push hl
       call vrampr
       ld hl,screen2tile
       ld bc,1*2
       call vramwr
       pop hl
       pop bc
       pop af
       ret

screen2tile      .dw $001E
  View user's profile Send private message
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Post Posted: Fri Jan 11, 2019 5:33 pm
Thank you so much! I'm using TomHarte's version and it works great.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!