Lesson H8- Hello World on the Sega Master System and GameGear

The Master System & GameGear are virtually the same hardware!
User avatar
akuyou
Posts: 562
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Lesson H8- Hello World on the Sega Master System and GameGear

Post by akuyou » Sun Sep 01, 2019 9:45 pm



http://www.chibiakumas.com/z80/helloworld.php#LessonH8

The Sega Mastersystem and GameGear are virtually the same system, so we can create one Hello World that will run on both systems.

Unfortunately, the SMS/GG have no firmware to help us, so we're going to have to create our own font, and work out how to get it to the screen... Lets go!
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Lee
Posts: 23
Joined: Sun Oct 10, 2021 1:26 am

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by Lee » Thu Jun 02, 2022 7:40 pm

Hi,

I am trying to learn sega master system/SMS programming. What I have done is taken the segaspriteandtilecolortestimage_testgraphics.BMP, attached in zip, which is an image of 16 tiles as a 4 by 4 square,or 32 by 32 pixels the first two tiles in this square starting from the top left, has the letter A in green boxed border and the letter b in a blue boxed border in the consecutive tile. I can get the tiles to show on the screen as background tiles (not sprites) with no problem (shown the A,b tles in top left as expected and using the code from the tutorials) showing the different colors in my defined palette. and using the .RAW file exported from akusprite. I am using the mode in the master system where the tile info is shared with the sprite info so a sprite will have the same graphics as some tile. I have defined tile 0 to be the letter boxed letter A and tile 1 to be the boxed letter b (lowecase of B). What the ASM program attached does is when the down key is pressed it show the sprites 0 and 1 (the boxed letters A and b) stuck together-side by side-moving down while the down key is pressed;but is only shows the letter A and b totally in black with no color -it does not show their different color borders-even though the palette for the sprites is all different colors as the code shows.

So how do I show the colors in the sprites (for the letters A and b) ? instead of just an all black sprites being showed?

Question’s files in the zipped file and below shows the code in running,
Attachments
captureofrunningsmsrom.JPG
captureofrunningsmsrom.JPG (103.79 KiB) Viewed 3115 times
SMSquestion.zip
(100.32 KiB) Downloaded 208 times

User avatar
akuyou
Posts: 562
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by akuyou » Thu Jun 02, 2022 10:07 pm

The SMS/GG has two 16 color palettes.
The background can use palette 0 or palette 1, but sprites always use Palette 1
You've only defined palette 0 - so the sprites are black

Double the entries in PaletteData (copy the existing 16 entries a second time for starters)
Change "ld b,16 ;Byte count (16 on SMS)" to 32 in the palette loading code

Your sprite will now be in color.
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Lee
Posts: 23
Joined: Sun Oct 10, 2021 1:26 am

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by Lee » Thu Jun 02, 2022 11:20 pm

So I changed that part from ld b,16 to ld,32 and wrote the same palette a second time into the master system CRAM.Which worked and so now the sprites show in color. :Wow: But what are the sixteen hex palette values that are for the SMS palette , chosen by the SMS palette setting option, in the Akusprite program? Which lesson would those palette values be in?

User avatar
akuyou
Posts: 562
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by akuyou » Thu Jun 02, 2022 11:26 pm

Palette settings are covered here:
https://www.chibiakumas.com/z80/platform2.php#LessonP16

It's just 2 bits per color channel though, so it's not too hard to figure out. The "--BBGGRR" in the file you sent should mark the correct bits that make up each color channel.

Theres a list of the platform specific lessons for the SMS on the page here:
https://www.chibiakumas.com/z80/MasterS ... meGear.php
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Lee
Posts: 23
Joined: Sun Oct 10, 2021 1:26 am

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by Lee » Fri Jun 03, 2022 1:05 am

Which lesson is it for hardware scrolling at 1 pixel at a time on the sega master system? I had a look but only found it for the gameboy

User avatar
akuyou
Posts: 562
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by akuyou » Fri Jun 03, 2022 3:42 am

I don't think I've done that, but I'm sure you can figure it out yourself!

Take a look at VDP regsiters:
&08 Background X Scroll T T T T T P P P T = Tile offset (0-31), P=Pixel offset
&09 Background Y Scroll T T T T T P P P T = Tile offset (0-27), P=Pixel offset
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Lee
Posts: 23
Joined: Sun Oct 10, 2021 1:26 am

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by Lee » Fri Jun 03, 2022 10:35 pm

I want to make a master system game in it that has a real time accurate clock counting upwards in hours,minutes and seconds.So how would I do that? I have coded an approximate counting clock showing on the screen using delay loops which is not accurate because after a while it differs in time counted compared to a real stopwatch or clock .The delay loop are only using the inc a instruction to increase memory value location which the clock is based on which is not the right way to do it because it is not accurate.

User avatar
akuyou
Posts: 562
Joined: Mon Apr 22, 2019 3:19 am
Contact:

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by akuyou » Sat Jun 04, 2022 1:08 am

The Vblank interrupt happens 50 times a second.
I think that's your best way to do timing. Put a counter routine in the interrupt handler.

I'm afraid I don't have a tutorial on SMS dedicated to interrupts, but they were mentioned in my lightgun tutorial

https://www.chibiakumas.com/z80/platform6.php#LessonP55
Chibi Akuma(s) Comedy-Horror 8-bit Bullet Hell shooter! // 「チビ悪魔」可笑しいゴシックSTG ! // Work in Progress: ChibiAliens

Interested in CPU's :Z80,6502,68000,6809,ARM,8086,RISC-V
Learning: 65816,ARM,8086,6809

Lee
Posts: 23
Joined: Sun Oct 10, 2021 1:26 am

Re: Lesson H8- Hello World on the Sega Master System and GameGear

Post by Lee » Sat Jun 04, 2022 6:29 am

Which lesson is it that includes the subroutine that is the reverse of your PrintChar subroutine? So it will take x and y coordinates on the sega master system screen and return the tile number value or ascii code of the character at position x and y. With x is less than 32 any y is less than 24.

Post Reply

Return to “Master System & GameGear Assembly Programming”