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 - [Coding competition 2015] Racer by hang-on

Reply to topic Goto page Previous  1, 2

Rate this entry!

1 (Poor) 0% 0%
2 0% 0%
3 0% 0%
4 0% 0%
5 17% 17%
6 21% 21%
7 34% 34%
8 8% 8%
9 (Excellent) 17% 17%
This poll has expired.
Author Message
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Tue Nov 24, 2015 6:27 pm
Haha - yeah, the difficulty was cranked down a little. Thanks for the suggestion - I'll have a look at vertical movement. But no promises, for soon the preparations for the compo must start... :)
  View user's profile Send private message Visit poster's website
  • Joined: 22 Mar 2015
  • Posts: 228
Reply with quote
Post Posted: Fri Mar 25, 2016 1:39 pm
Hi; I like this game is very challenging btw, the case is I was using this for self-learning and I dont figure out how to change the color to the car I've used Ps7.04 to edit the palette to the "player tiles" but the player car is still the same, then I changed the colour of the sprite palette that's the way how I changed the player car colours.

So my question is if the tiles palette by PS 7.04 is changed then they have to be in the sprite palette to work??

And could anyone teach me how to edit pixel by pixel the colour of any tile/sprite in Paintshop 7.04??
  View user's profile Send private message
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Fri Mar 25, 2016 7:24 pm
Hi FeRcHuLeS.

Thanks for spending time with Racer and the tutorial! I assume it is the classic version of Racer you are working with.

If you want to hack the palette of Racer, you might want to open the file called 'sprites (palette).inc' in the Assets folder.

;.db $23 $17 $3F $22 $35 - comment out original sprite palette.
.db $23 $17 $0c $22 $35 ; third byte is changed


In the example above I changed the third color (the third byte) from $3f to $0c - and it makes the enemy cars turn bright green instead of their usual relaxed white.

You can look up all the colors in Maxim's tutorial. I recommend that you start with Maxim's Hello World tutorial to really get a good start in SMS-programming.

EDIT: To change the color of the player car, go to line 339 in main.asm:

; Adjust the sprite palette (player might be cyan).

       ld a,$11            ; player car's color.
       ;ld b,%00010111     ; set it to default orange. (comment out)
       ld b,$20            ; - tweak color of player car.
       call setcol         ; do it.


Again referring to Maxim's color chart, I have commented out a line and replaced it with an instruction to load $20 (dark blue) into the palette spot that holds the player car's color. This color is set at every new attempt/game, because the player car might have switched colors during the race (if hiscore is beaten).
  View user's profile Send private message Visit poster's website
  • Joined: 22 Mar 2015
  • Posts: 228
Reply with quote
Post Posted: Sat Mar 26, 2016 1:18 am
Tnank you very much, now I know how to change the player car and the other cars colour, and I figure out how to change the background palette, and the cars shape by Paint (windows) and Maxim's BMP2tile.
And I'm trying to add the tires movement effect could you give some tips on how to do it? If I achieve this I'll be releasing my hack as long as you agree.

I already finished Maxim's Hello World btw, thanks again :)
  View user's profile Send private message
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Sat Mar 26, 2016 7:16 am
You are welcome! :) And congratulations on making sprite shape modifications work. I will look forward to see your hack.

If you want to have simple animations (still assuming Racer classic), I would recommend having a counter decremented each frame. When it reaches zero, you will update the player sprite, similar to when the player car crashes:

       ld hl,crash         ; point to crashed car graphics.
       ld de,plrcc         ; point to player cc buffer start.
       call carcc          ; set the player's sprites to crash!


And when the counter reaches zero again, switch back.

Relevant data here:

plrcar .db 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
crash .db 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47


... where you will have to add a string with indexes to where in the tilebank your new tiles reside.

You will of course have to load your modified tiles into vram along with the other assets as the racetrack loads.

See also posts by Orlan_Rod and GameGearGuy, as they have experimented with hacking Racer as well.

Happy working! :)
  View user's profile Send private message Visit poster's website
  • Joined: 22 Mar 2015
  • Posts: 228
Reply with quote
Post Posted: Sun Apr 03, 2016 1:29 am
Hey, no luck with tires movement yet, and there are things that I didnt figure out:

I want to ask an explanation on how the interrupts work I'm at a loss and not sure what(cpu, vdp, ram) is involved with interrupts I identify flag interrupts, line interrupts, frame interrupts and so on.

I found this instruction "halt" how is related to di ei reti instructions or interrupts?

This code confuses me aswell

.orga $0038
        ...
        ...
        ei                  ; enable interrupts.
        reti                ; return from interrupt.


Why they have to be one after the other as they seem to be opposite instruccions (something like inc and dec).

I beg you please clear all my doubts .;(
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 878
Reply with quote
Post Posted: Sun Apr 03, 2016 6:57 am
FeRcHuLeS wrote
I found this instruction "halt" how is related to di ei reti instructions or interrupts?

The instruction halt makes the cpu wait for the next frame interrupt. You put it in your code if you have finished everything you want it to do in one frame. Otherwise the system would simply proceed with the next instructions and your program would run too fast.

As sometimes you want to do something you do not want to have interrupted by any means (like loading and decompressing tile data for example),di disables the interrupt mechanism, ei re-enables it.

FeRcHuLeS wrote
This code confuses me aswell

.orga $0038
        ...
        ...
        ei                  ; enable interrupts.
        reti                ; return from interrupt.


Why they have to be one after the other as they seem to be opposite instruccions (something like inc and dec).

They are not - reti is pretty much the same as ret, but instead of using it to return from a regular called routine, you use it to return from your interrupt handler.
  View user's profile Send private message
  • Joined: 23 Mar 2013
  • Posts: 611
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Sun Apr 03, 2016 7:19 am
Yes - Kagesan is of course right :) I will just add that the halt instruction does not only wait for the frame interrupt. Also pressing pause (the non-maskable interrupt) counts as well. That puzzled me when I coded Racer, until Calindro explained the details to me.

From the tutorial:" The halt opcode will also resume program flow when returning from the pause button interrupt handler, not only from the frame interrupt. For a long time, this resulted in a bug, where pressing the pause button instantly killed the player. See the discussion i Racers thread, and read more at the end of this document. "
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3828
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Sun Apr 03, 2016 5:17 pm
Kagesan wrote
The instruction halt makes the cpu wait for the next frame interrupt.


Any interrupt, actually. It could be frame, line, NMI or whatever.
  View user's profile Send private message Visit poster's website
Reply to topic Goto page Previous  1, 2



Back to the top of this page

Back to SMS Power!