Sprite Isn't Showing Up

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Re: Sprite Isn't Showing Up

Post by BigEvilCorporation » Wed Sep 16, 2015 8:13 am

Similar principle, but with some DIVs instead of shifts.

For a 10 base number you need a combination of divisions and modulus (DIV.L stores modulo in upper word, exponent in lower word). In theory, to convert the number 2348:

Code: Select all

2348 % 10 = 8
2348 / 10 = 234, then 234 % 10 = 4
234 / 10 = 23, then 23 % 10 = 3
23 / 10 = 2, then 2 % 10 = 2
2 / 10 = 0
(taken from here: http://www.atari-forum.com/viewtopic.php?t=15130).

See how you get on. I won't be at home until Monday so let me know if you run into trouble and I'll see if I can write a routine next week.
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Sprite Isn't Showing Up

Post by Sik » Fri Sep 18, 2015 12:20 am

DIVU would fail to work properly with numbers larger than 655350 due to the result being only 16-bit, however. (DIVS would fail with larger than 327670) There's also the fact that it takes about 140 cycles for each division (whether this is an issue or not depends on the situation, for one or two small numbers in a HUD it probably isn't much of a problem).

An alternative if you need this to work with larger numbers is to check each bit individually and add them, but doing the additions in BCD, then you can just treat the BCD result as a hexadecimal number. This is faster than divisions (especially if you optimize using look-up tables to process multiple bits at once) and doesn't have issues with large numbers, it's way less obvious and trivial, however.
Sik is pronounced as "seek", not as "sick".

BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Re: Sprite Isn't Showing Up

Post by BigEvilCorporation » Fri Sep 18, 2015 9:11 am

A solution for a fixed digit score counter was mentioned over at AssemberGames:

Store a string of '0' chars in RAM ("00000000"), and increment the bottom byte for each point awarded, then iterate each digit checking for overflow (clamp to 9 and add 1 to the next char, etc).

Obviously it's very primitive and only serves a specific purpose, but since I'm looking to create a fixed-digit score counter at some point the idea appealed to me. It's also branch heavy but I wonder how it performs against a load of DIVs. It also frees you of longword length numbers, if you want ridiculously high scores in the trillions (would need support for adding 1, 10, 100, 1000, 10000, 100000, 1000000, etc, though).
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

lorix
Newbie
Posts: 4
Joined: Sat Aug 30, 2014 12:37 pm
Location: Italy

Re: Sprite Isn't Showing Up

Post by lorix » Fri Sep 18, 2015 1:53 pm

For the decimal conversion you can also check out my Phantasy Star disassemblies on RHDN. I found the algorithm on PSII and IV; they have the same logic and use an array of 1, 10, 100, etc., which are the number of digits for the conversion. Before converting, it loads the number of digits and then stores the number of digits in the register for a loop, thus it's 0-based; however you should read the PSII one since I put comments there. Hope it will help a bit. You can search for words like 'convert' or 'conversion' and you should be able to find the subroutine easily

SegaDev
Interested
Posts: 19
Joined: Sat Jul 11, 2015 4:09 am

Re: Sprite Isn't Showing Up

Post by SegaDev » Sat Sep 19, 2015 10:29 pm

BigEvilCorporation wrote:A solution for a fixed digit score counter was mentioned over at AssemberGames:

Store a string of '0' chars in RAM ("00000000"), and increment the bottom byte for each point awarded, then iterate each digit checking for overflow (clamp to 9 and add 1 to the next char, etc).

Obviously it's very primitive and only serves a specific purpose, but since I'm looking to create a fixed-digit score counter at some point the idea appealed to me. It's also branch heavy but I wonder how it performs against a load of DIVs. It also frees you of longword length numbers, if you want ridiculously high scores in the trillions (would need support for adding 1, 10, 100, 1000, 10000, 100000, 1000000, etc, though).
The problem isn't about how to manage the score but, how do convert it from integer to ASCII which is the way the font system works in "The Big Evil Corporation Framework"(Hope you don't mind i named your framework :mrgreen: ). I am going to use overflows and branches to manage the score part. However if i pass an integer value to DrawTextPlaneA nothing shows up and that's because it's expecting an ASCII value. I managed to convert the hex function i was provided to display only numeric values, but sadly i am not around my development PC to test it currently. That is unless I'm misunderstanding something.....

Sincerely,

SegaDev

BigEvilCorporation
Very interested
Posts: 209
Joined: Sat Sep 08, 2012 10:41 am
Contact:

Re: Sprite Isn't Showing Up

Post by BigEvilCorporation » Sun Sep 20, 2015 9:18 am

SegaDev wrote:"The Big Evil Corporation Framework"(Hope you don't mind i named your framework :mrgreen: )
Close, it's BEE (Big Evil Engine) :)

I need to write some test programs and do a real release. I even have a map editor for it!
SegaDev wrote: I managed to convert the hex function i was provided to display only numeric values
Post it when you get a chance, I'd be interested in seeing it!
A blog of my Megadrive programming adventures: http://www.bigevilcorporation.co.uk

Post Reply