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 - Game Gear and white

Reply to topic
Author Message
  • Joined: 06 Sep 2015
  • Posts: 263
  • Location: United States
Reply with quote
Game Gear and white
Post Posted: Thu Mar 18, 2021 9:20 pm
Help! I want to change a color in the color palette to white, but I can't figure out what values I need. I've tried everything and nothing will make it white. I've made it blue, green, pink, but not white. What do I need to do?! What's worse is this code makes it a bright green and not black.

       ld hl,$c022
       call vrampr
       ld hl,%0     
       ld bc,1
       call vramwr

       ld hl,$c023
       call vrampr
       ld hl,%0     
       ld bc,1
       call vramwr
  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: Fri Mar 19, 2021 12:16 am
I got it to display white, but I don't know how. The color and palette make no sense to me. This code makes palette color #2 be white, although I don't know how.

       ld hl,$c022
       call vrampr
       ld hl,$ca
       ld bc,1
       call vramwr

       ld hl,$c023
       call vrampr
       ld hl,$ca
       ld bc,1
       call vramwr
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14690
  • Location: London
Reply with quote
Post Posted: Fri Mar 19, 2021 7:22 am
You don’t make it clear what your functions do so it’s hard to help you. My guess is that your vramwr function copies bc bytes from address hl to the VDP, which you’ve already pointed to a palette address in the $c000 range. That means to set one entry to white, you need to make bc equal to 2 (2 bytes) and make hl the address of white data, not hold the value itself. Otherwise you’re likely writing code values from the addresses you are using. I’d have something like this:

; somewhere outside a function
White: .dw $0fff

; elsewhere in the code
ld hl,White
ld bc,2
call vramwr
  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 Mar 19, 2021 12:37 pm
each palette entry on a Game Gear takes two bytes, and you have to write them to VDP address $c000 + palette entry*2

it's way harder if you try to randomly change the code without knowing what to do
  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: Fri Mar 19, 2021 4:42 pm
Sorry. here's the other code I was using.

vrampr push af
       ld a,l
       out ($bf),a
       ld a,h
       or $40
       out ($bf),a
       pop af
       ret

vramwr ld a,(hl)
       out ($be),a
       inc hl
       dec bc
       ld a,c
       or b
       jp nz,vramwr
       ret
  View user's profile Send private message Visit poster's website
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Fri Mar 19, 2021 6:57 pm
Hi,

It seems like you use the Racer subroutines: :)

; --------------------------------------------------------------
; SUBROUTINES
; --------------------------------------------------------------
; PREPARE VRAM.
; Set up vdp to recieve data at vram address in HL.

vrampr push af
       ld a,l
       out ($bf),a
       ld a,h
       or $40
       out ($bf),a
       pop af
       ret

; --------------------------------------------------------------
; WRITE TO VRAM
; Write BC amount of bytes from data source pointed to by HL.
; Tip: Use vrampr before calling.

vramwr ld a,(hl)
       out ($be),a
       inc hl
       dec bc
       ld a,c
       or b
       jp nz,vramwr
       ret


sverx and Maxim are of course right: The problem lies in the palette differences between the Game Gear (two bytes per color) and the Master System (1 byte per color). Racer was written for the Master System...
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14690
  • Location: London
Reply with quote
Post Posted: Sat Mar 20, 2021 8:08 am
Also the write function takes a pointer to data, not data itself. This can be difficult for people to understand sometimes.
  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: Mon Mar 22, 2021 10:33 am
also vrampr isn't interrupt safe and, for some reason, preserves the contents of registers AF - which is something he probably doesn't even need
  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!