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 2017] Astro Force by eruiz00

Reply to topic Goto page Previous  1, 2, 3  Next

Rate this entry!

1 (Poor) 0% 0%
2 0% 0%
3 0% 0%
4 0% 0%
5 0% 0%
6 4% 4%
7 4% 4%
8 45% 45%
9 (Excellent) 45% 45%
This poll has expired.
Author Message
  • Joined: 14 Apr 2013
  • Posts: 430
Reply with quote
Post Posted: Sat Apr 01, 2017 11:51 pm
Kagesan wrote
BKK wrote
What hardware are you having issues with?

Master Everdrive and SMS 1 (originally PAL, but modded to 60 Hz).

In the intro, the first part doesn't display the text, just the picture of the planet. Second part only shows a black screen. Third part shows the scrolling city scape, but not the ship sprite.

Title screen looks normal, but the game freezes on the next screen, regardless of the button pressed. While the options menu looks otherwise normal, the stage select screen shows varying messed up tiles.

Music plays fine throughout. Both versions of the game behave exactly the same, btw.

When running Emulicious emulating the Master Everdrive with an old version of the OS (e.g. version 4) you can see exactly what you describe (You need to load the game via "Select Game". It won't happen via "Start Game".)
The issues are caused by the Master Everdrive OS not loading the whole rom. Old versions of the Master Everdrive OS expect filesizes that are a multiple of $10000 (4 banks). It seems to be fixed in recent versions (e.g. version 8).
To fix compatibility with old versions of the Master Everdrive OS you might want to pad your romfile to 256 KB (16 banks).
Having 16 banks instead of 14 has the additional advantage of being a power of 2. Some emulators rely on the number of banks to be a power of 2 so padding to a power of 2 should greatly improve compatibility of your game.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sun Apr 02, 2017 12:06 am
Always saw strange that weird size... but never can imagine that. Anyways the final rom will have 256kb with the new content :)
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 355
Reply with quote
Post Posted: Sun Apr 02, 2017 9:06 am
Calindro is the hero of the day. Updating my Everdrive's OS from v4 to v8 did indeed solve the problem.

@eruiz00: Please set up left column blank in the VDP registers. There's a column of garbage popping up on the left edge of the screen whenever you're scrolling horizontally.
  View user's profile Send private message
  • Joined: 12 Oct 2015
  • Posts: 42
  • Location: Ireland
Reply with quote
Post Posted: Sun Apr 02, 2017 12:36 pm
haroldoop wrote
That's a fantastic looking shoot-em-up. All it really needs is some power ups.
The fact that it comes with C source gives me some ideas for a future project. ;)

Could someone please direct me to the source code? I only get one file "astroforcev2.sms" when I unzip from the AstroForce-SMS-1.01.zip download link [http://www.smspower.org/uploads/Homebrew/AstroForce-SMS-1.01.zip] Thanks
PS: I was finally able to run this on my SMS I at 50Hz and saw only some minor graphics glitches on the first column left hand side on the horizontal scrolling intro screen but nothing during game play
  View user's profile Send private message Visit poster's website
  • Joined: 14 Apr 2013
  • Posts: 430
Reply with quote
Post Posted: Sun Apr 02, 2017 12:44 pm
SteveProXNA wrote
haroldoop wrote
That's a fantastic looking shoot-em-up. All it really needs is some power ups.
The fact that it comes with C source gives me some ideas for a future project. ;)

Could someone please direct me to the source code? I only get one file "astroforcev2.sms" when I unzip from the AstroForce-SMS-1.01.zip download link [http://www.smspower.org/uploads/Homebrew/AstroForce-SMS-1.01.zip] Thanks
PS: I was finally able to run this on my SMS I at 50Hz and saw only some minor graphics glitches on the first column left hand side on the horizontal scrolling intro screen but nothing during game play

The source is contained in the original file. Look for "Old Versions" on the Homebrew page.
  View user's profile Send private message Visit poster's website
  • Joined: 12 Oct 2015
  • Posts: 42
  • Location: Ireland
Reply with quote
Post Posted: Sun Apr 02, 2017 12:52 pm
Calindro wrote
The source is contained in the original file. Look for "Old Versions" on the Homebrew page.

Thanks Calindro! I see it now [http://www.smspower.org/uploads/Homebrew/AstroForce-SMS-1.00.zip]
  View user's profile Send private message Visit poster's website
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Sun Apr 02, 2017 1:48 pm
eruiz00 wrote
Anyways the final rom will have 256kb with the new content :)


2 mega power ! :) you still have lots of more room if needed :p
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sun Apr 02, 2017 2:02 pm
Ummmm.... It will take half a week to upload, but it feels by far more polished. Faster bullets, faster player, more balanced playability, remaded graphics (these tanks...) color degradations on sprites, powerups, blitting at start, left column hidden, some new effect here and here, clouds in jungle stage, and a (now thinking concept, although music it has been done last hour) new stage (have a entire bank and 0x0500 code free to waste!) . Maybe some additional new music for bosses. Will upload the final src, but it has been turned into a function pointer table hell, and many common sub functions trees to wrap common patterns.
  View user's profile Send private message
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Sun Apr 02, 2017 2:33 pm
eruiz00 wrote
Ummmm.... It will take half a week to upload, but it feels by far more polished. Faster bullets, faster player, more balanced playability, remaded graphics (these tanks...) color degradations on sprites, powerups, blitting at start, left column hidden, some new effect here and here, clouds in jungle stage, and a (now thinking concept, although music it has been done last hour) new stage (have a entire bank and 0x0500 code free to waste!) . Maybe some additional new music for bosses. Will upload the final src, but it has been turned into a function pointer table hell, and many common sub functions trees to wrap common patterns.


I would say take your time developing the game because you might come with some new ideas and more details before you complete everything . A new stage sounds great and additional music is welcome to.
But I'd say take your time because as you said things also turned a bit more complicated coding -wise and youre the only person developing the game with an extra help from forum members.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sun Apr 02, 2017 2:55 pm
My bad english fooled myself. Got it!
  View user's profile Send private message
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Sun Apr 02, 2017 3:03 pm
eruiz00 wrote
My bad english fooled myself. Got it!

Your English is fine imo btw other day finished aerial assault and theres a typo saying something like ''thanks for saving the peoples of the earth'' lol :p so don't worry about it , you're doing your best and I have a lot of respect for this original work of yours since you brought all this up by yourself.
  View user's profile Send private message
  • Joined: 23 Mar 2013
  • Posts: 526
  • Location: Copenhagen, Denmark
Reply with quote
Post Posted: Thu Apr 06, 2017 5:32 pm
I'm late to the Astro Force party, but just wanted to say congrats on this impressive game! I can fully appreciate all the hours you must have put into it. The music is really great, and sounds very authentic, emphasizing the 80's shooter vibe you got going here :) Even with 6 lives and easy mode, I think this game is brutally hard!
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Thu Apr 06, 2017 10:05 pm
Jaja yes it is :) although i finish it with two continues (have played the game the same time as i have been developing it). Im more relaxed now (im playing with fake 3d effects for the last stage im doing) but if i finish the game will be a bit easier but with faster gameplay. Also, playing bruce lee of kagesan. A very good one!
  View user's profile Send private message
  • Joined: 22 Mar 2015
  • Posts: 123
Reply with quote
Post Posted: Wed Apr 12, 2017 3:29 pm
It's a pretty good job this game, music, graphics the only complaint I have is the speed, Can you consider increasing the left/right speed? this makes the game really hard.
  View user's profile Send private message
  • Joined: 01 Jan 2014
  • Posts: 302
Reply with quote
Post Posted: Thu Apr 13, 2017 10:40 am
Very polished and complete. Most of the critique for is gameplay related and has been mentioned by others. I do think in particular the ships coming from bottom of screen in cave level is a bit too much and the bosses have too much health.

Visually it gives off a crisis force vibe, very nice use of hardware with parallax, animations and palette swapping and all done in c. Very impressive overall.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Fri Apr 14, 2017 3:20 pm
psidum wrote
Most of the critique for is gameplay related and has been mentioned by others. I do think in particular the ships coming from bottom of screen in cave level is a bit too much and the bosses have too much health.


Yeah.... i'm finishing almost now the last (holy week you know... it's a promise) version, which tries to fix all complaints. I'm very happy as it has many new enemies, fixes, music, graphics... even a new stage, keeping the code size smaller than before (almost everything which can be uploaded to banks, doing data based common code, is translated). I want to finish as soon as possible (testing is the last thing i have to do) to begin the new project i have in mind.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Sat Apr 15, 2017 12:38 pm
Well.... here is the final version. Bock please replace older by this.

A resume:

- A new stage, with bosses and everything
- Redesign of weakest graphics
- All music is modified to be less noisy
- Some effects in some stages
- Powerup system
- More enemies put on scene, as you need kill enemies to obtain powerups
- Pause
- New song (alternate) for enemies
- Better enemy shooting. Now enemies does not shoot player if it is near.
- Better code organization. More things in less space. Have learned very much doing this.
- Faster playability. Also easier. Now i finish the game without continues (not easy, but possible).
- More improvements, those which where made by friends here and have been possible.

Was a fun time. Now can start a new project. Enjoy!
astroforce-final-src.rar (791.79 KB)
src and assets
astroforce-final.rar (131.42 KB)
SMS file

  View user's profile Send private message
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Sun Apr 16, 2017 5:08 pm
eruiz00 wrote
Well.... here is the final version. Bock please replace older by this.

A resume:

- A new stage, with bosses and everything
- Redesign of weakest graphics
- All music is modified to be less noisy
- Some effects in some stages
- Powerup system
- More enemies put on scene, as you need kill enemies to obtain powerups
- Pause
- New song (alternate) for enemies
- Better enemy shooting. Now enemies does not shoot player if it is near.
- Better code organization. More things in less space. Have learned very much doing this.
- Faster playability. Also easier. Now i finish the game without continues (not easy, but possible).
- More improvements, those which where made by friends here and have been possible.

Was a fun time. Now can start a new project. Enjoy!


Superb work ! Congratulations! :)))
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 355
Reply with quote
Post Posted: Mon Apr 17, 2017 8:27 am
Very nice work. The new ship speed makes it easier to actually dodge something, and the powerups are most welcome. Overally, though, I feel that the game actually got harder rather than easier due to the faster and more numerous enemy bullets. I also feel that the game now relies a little too much on the player having powerups activated, as losing your powerups (and speedups!) in the middle of a fierce wave means you can just as well reach for the reset button. Additionally, where there was a nice balance of strategical use of front and side cannons before, now you're getting the farthest with just the double front cannon.

I still think it's a problem that the player can neither move or shoot while a new ship is being readied after a death while enemies keep pouring on screen, and that the invulnaribility period is woefully short. I had several games end with 5 deaths in a row without even the slightest chance of escaping the consecutive hits.
  View user's profile Send private message
  • Joined: 22 Mar 2015
  • Posts: 123
Reply with quote
Post Posted: Mon Apr 17, 2017 3:57 pm
Still hard for me I can't beat a single stage, nevertheless I was never good at this kind of games but please do you mind making a checkpoint in the middle of the stage from where we can continue instead of continuing from the begining??
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Mon Apr 17, 2017 4:47 pm
Ummm... i must confess i consider myself a good shmup player which terminate things like ikaruga or gradius v without trouble (rsg is other story). Thats why the game is hard. I wanted to do a nervous play in which you have to stay concentrated. Maybe playing it with a keyboard is helpful.

But if there are complaints i am wrong for sure. Sorry guys. Lets tune the game to finish it properly.

For developers: in vars.h set enemyshoot_density to a higher value. In defines.h set enemyshoot_speed to a lower one. cc.bat to compile.

For players (i am very grateful for know this game is being played) this night ill upload a version with some additional difficulty level (normal-》hard, new normal easier mode) maybe should be slower and less bullets

Last but not least. I have tested the game in miracle.js emulator and is impressive (the emulator) sounds like emulicious and plays as fast as java! Sincere congratulations to his author.

Regards!
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 11905
  • Location: London
Reply with quote
Post Posted: Mon Apr 17, 2017 5:25 pm
We need to integrate one of those JS emulators with the homebrew section...
  View user's profile Send private message Visit poster's website
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Mon Apr 17, 2017 8:07 pm
eruiz00 wrote
Ummm... i must confess i consider myself a good shmup player which terminate things like ikaruga or gradius v without trouble (rsg is other story). Thats why the game is hard. I wanted to do a nervous play in which you have to stay concentrated. Maybe playing it with a keyboard is helpful.

But if there are complaints i am wrong for sure. Sorry guys. Lets tune the game to finish it properly.

For developers: in vars.h set enemyshoot_density to a higher value. In defines.h set enemyshoot_speed to a lower one. cc.bat to compile.

For players (i am very grateful for know this game is being played) this night ill upload a version with some additional difficulty level (normal-》hard, new normal easier mode) maybe should be slower and less bullets

Last but not least. I have tested the game in miracle.js emulator and is impressive (the emulator) sounds like emulicious and plays as fast as java! Sincere congratulations to his author.

Regards!


I don't have any problems with shooters being hard , i think hard games are by far a greater challenge and makes the game last way but way longer. Thumbs up for that.
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Mon Apr 17, 2017 8:36 pm
Me too. But that is the funny thing about this. Developer support :)

Lets see...

-Inmune time is doubled.
-old easy mode is now hard mode. Easy mode is easier. It was funny finish the game without continues.
- bosses are a bit weaker. This has been modified because some are too long if you have not double shoot.
- shoots are a bit slower.
- some boss shoot patterns are more human avoidable.

Sorry admin im going to turn you crazy with this updates.

Regards.
astroforce-playable.7z (124.37 KB)

  View user's profile Send private message
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Mon Apr 17, 2017 10:10 pm
eruiz00 wrote
Developer support :)

Lets see...




Happy to be of help. :)
All the best buddy and keep up the great and awesome work!
  View user's profile Send private message
  • Joined: 01 Feb 2014
  • Posts: 355
Reply with quote
Post Posted: Tue Apr 18, 2017 4:30 pm
Congratulations! I think you just about hit the sweet spot. The game is very playable now while still offering a decent challenge. I'll try and get that 1CC on default settings...
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Tue Apr 18, 2017 9:22 pm
Most important thing for the end but i agree. Now is better. Im beggining a new project just now. News soon. Its going to be a more complex game.
  View user's profile Send private message
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Wed Apr 19, 2017 5:37 am
eruiz00 wrote
Most important thing for the end but i agree. Now is better. Im beggining a new project just now. News soon. Its going to be a more complex game.


Looking forward to it :)
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 319
  • Location: Spain
Reply with quote
Post Posted: Wed Apr 19, 2017 7:32 am
I'm also looking forward for it! :-D
  View user's profile Send private message
  • Joined: 14 Apr 2013
  • Posts: 430
Reply with quote
Post Posted: Thu Apr 20, 2017 8:01 pm
I've just uploaded the new versions to the Homebrew page. As you didn't mention any version numbers I just continued the previous versioning scheme. If you want different numbers let me know.
  View user's profile Send private message Visit poster's website
  • Joined: 27 Feb 2017
  • Posts: 145
  • Location: Northern Ireland
Reply with quote
Post Posted: Fri Apr 21, 2017 1:48 pm
Calindro wrote
I've just uploaded the new versions to the Homebrew page. As you didn't mention any version numbers I just continued the previous versioning scheme. If you want different numbers let me know.


happy days ^_^
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Fri Apr 21, 2017 5:05 pm
Glad to hear! This is kind of energy i need just now im beggining new project and have new problems to solve...
  View user's profile Send private message
  • Joined: 31 Oct 2007
  • Posts: 808
  • Location: Estonia, Rapla city
Reply with quote
Post Posted: Sun Apr 23, 2017 11:52 am
I like the music but control is control is stiff and it is easy to get cheap shots from behind you because you stayed in wrong part of the screen.
I liked the music and graphics, very nice work on those ~
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Tue Apr 25, 2017 5:10 pm
Thanks all!!!

... but now its time to make new things. Like a new game. See soon!!!
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 319
  • Location: Spain
Reply with quote
Post Posted: Thu Apr 27, 2017 12:22 pm
I know you said that you we're not planning to put the code in a GitHub repository, but..would you mind if I put it in mine just for reference for future developers? (with proper reference to you and disclaiming that I haven't been involved in the project at all)
  View user's profile Send private message
eruiz000
  • Guest
Reply with quote
Post Posted: Fri Apr 28, 2017 5:41 pm
Ok sir.

Remember some years ago i did other smaller shmup , tululoo shoot, which i saw on some sites with the authorship modiffied :(

As its clear this is not the point here, ill be as kind as you asking, so go for it. Maybe in a future someone make a better game based on the engine or a better one. Long life SMS!
 
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Fri Apr 28, 2017 5:42 pm
Sorry i forgot to login. Its me kusfo!
  View user's profile Send private message
  • Joined: 29 Mar 2012
  • Posts: 319
  • Location: Spain
Reply with quote
Post Posted: Sat Apr 29, 2017 6:47 pm
Here it is! :-D

https://github.com/kusfo/astroforce
  View user's profile Send private message
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Mon Jun 05, 2017 6:35 pm
Although this could seem an obvious question... does astroforce run slowly at 50hz? If i put it at 50 hz on an emulator it runs slower than 60hz. If i had made it thinking the opposite way it should run too fast at 60hz.... i am planning to buy a sms with a everdrive... and although i am on spain, i think can buy an ntsc model and plug it to an led tv model. I am wrong with this? Someone commenting differences between ntsc/pal versions at game speed?
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 1962
Reply with quote
Post Posted: Mon Jun 05, 2017 9:20 pm
you don't actually need an NTSC console, you can fit a 50/60 Hz switch into a PAL model. I did it with my SMS II PAL console so that I can play games both at 50 or at 60 Hz. It's really that easy.
  View user's profile Send private message Visit poster's website
  • Joined: 01 Feb 2014
  • Posts: 355
Reply with quote
Post Posted: Tue Jun 06, 2017 10:47 am
All games run about 17% slower on a 50Hz machine (compared to a 60Hz one).
  View user's profile Send private message
eruiz000
  • Guest
Reply with quote
Post Posted: Tue Jun 06, 2017 12:35 pm
Ummm.... i will have to think a method to fix that difference. Maybe decoupling sprite and scroll updates of game logic update (using additional counters) Not only for astroforce, also for new platformer game (which is yet decoupled, although everything runs now on a waittovblank basis)... interesting problem here :)
 
  • Joined: 05 Sep 2013
  • Posts: 1962
Reply with quote
Post Posted: Tue Jun 06, 2017 2:34 pm
it's quite hard to make game logic run at 60 Hz and screen logic run at 50 Hz, so I suggest you that if you really want to do that, you simply let the logic run at the screen rate and have different coefficients for movements and so. For instance, if your movement is 1.0 pixel/frame at 60 Hz, you should move at 1.2 pixel/frame when running at 50 Hz so that your hero will move 60 pixel after one second in each case.

Or just don't bother, which is what happened at the time in most cases.
  View user's profile Send private message Visit poster's website
  • Joined: 26 Jan 2014
  • Posts: 414
Reply with quote
Post Posted: Wed Jun 07, 2017 12:46 am
Please, never stop working on this game.

Jamais dire jamais.
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 11905
  • Location: London
Reply with quote
Post Posted: Wed Jun 07, 2017 6:59 am
This is a good example of why it's worth the effort to make your game logic all fixed point, the gameplay is much smoother anyway but it also makes it fairly trivial to fractionally adjust the speed.
  View user's profile Send private message Visit poster's website
eruiz000
  • Guest
Reply with quote
Post Posted: Wed Jun 07, 2017 6:56 pm
Yeah! Many (many!) Years ago remember my demoscene fixed point years (to draw things like mode 7 vga scroller or draw textured non perspective triangles in rudimentary 3d 256 color engines)

But, talking of sms, maybe so many shls could retard too much. Well try anyways!

Today has been a sad day for me, so i am going to take two wines. Tomorrow will be a new day full of excitement for sure!

Kind regards everyone
 
  • Joined: 05 Sep 2013
  • Posts: 1962
Reply with quote
Post Posted: Wed Jun 07, 2017 7:39 pm
Fixed point on SMS (and I'd say on the Z80 in general) means 8.8 so you actually won't need any shift to extract the integer part.
Just cast (variable>>8) to char (unsigned is always better if possible) and that's it.
  View user's profile Send private message Visit poster's website
  • Joined: 28 Jan 2017
  • Posts: 272
  • Location: Málaga, Spain
Reply with quote
Post Posted: Wed Jun 07, 2017 8:17 pm
I see... so i must use integer operations and do >>8 shifts to take the high char?

Could not be better to do something else like pointing to the high part of the int? Maybe an union of an int and two chars? (Not sure if sdcc have unions)

IN my new platformer i am using unsigned ints for position as some maps are big (up to 2048x512) so i think should take a middle solution (>>4) so no joy :(
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 11905
  • Location: London
Reply with quote
Post Posted: Wed Jun 07, 2017 10:04 pm
I'd go to 24 bit numbers in assembly if needed, it's harder to express that in C. I don't know how well the optimizer can convert a shift by 8 into a read of the high byte (or register), it's going to hurt a lot to shift 8 bits and the C specs for the meaning of these shifts can be counterproductive.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 1962
Reply with quote
Post Posted: Thu Jun 08, 2017 7:00 am
eruiz00 wrote
Could not be better to do something else like pointing to the high part of the int? Maybe an union of an int and two chars? (Not sure if sdcc have unions)


sure, you could try with unions too... but it isn't so hard to just use plain ints and defining a macro to get the integer part:
#define UFIX(x)      ((unsigned char)((x)>>8))

and then use it as in
x=UFIX(WaimanuX)

which turns into the single asm instruction
ld   a,(#_WaimanuX + 1)

which directly reads the upper byte from the unsigned int variable. I really can't imagine a faster and simpler approach.

If you need to use a big map you could switch to 16.16 (with unsigned long) and extract the first 16 bytes (the unsigned int) the same way. I never tried that myself but it should work... :)
  View user's profile Send private message Visit poster's website
Reply to topic Goto page Previous  1, 2, 3  Next



Back to the top of this page

Back to SMS Power!