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 - Will there ever be more programming tutorials?

Reply to topic
Author Message
  • Joined: 23 Aug 2005
  • Posts: 31
  • Location: UK
Reply with quote
Will there ever be more programming tutorials?
Post Posted: Sun Dec 22, 2019 8:08 pm
I've tried a few times to get up and running with Sega Master System programming. I followed the setup for with ConTEXT, poured over the code, compiled the program, wrote it to an SD card, fired it up on my hardware etc.. all was going well until the tutorial abruptly stops. These tutorials seemed like they could have been an absolutely invaluable resource and I wonder if there is any plan to continue them?

Regards
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13144
  • Location: London
Reply with quote
Post Posted: Sun Dec 22, 2019 9:50 pm
I guess you mean at https://www.smspower.org/maxim/HowToProgram - the answer is, probably one day but maybe not very soon.
  View user's profile Send private message Visit poster's website
  • Joined: 08 Sep 2018
  • Posts: 227
Reply with quote
Post Posted: Sun Dec 22, 2019 9:54 pm
I hope so too, It helped a lot on setup.

This one actually helped me get going on a full game, though I wish we had some good tutorials on NPC setup and behavior scripting.

If you want to continue try this, its just as helpful.
https://www.smspower.org/Articles/CreateARacingGame
  View user's profile Send private message
  • Joined: 23 Aug 2009
  • Posts: 113
  • Location: Seattle, WA
Reply with quote
Post Posted: Mon Dec 23, 2019 12:52 am
I’m doing all my dev in VSCode and that’s x-platform and way nicer than ConText + batch files. So yeah, it could use an update.
  View user's profile Send private message
  • Joined: 23 Aug 2005
  • Posts: 31
  • Location: UK
Reply with quote
Post Posted: Mon Dec 23, 2019 1:01 am
@Maxim - I know these things are a lot of effort but really, I think that this type of effort is really awesome for the historic preservation and I would love to be able to get involved in this stuff. Hope to see some tutorials in the future. :)

@IllusionOfMana - That link is incredible so thank you!!

@SavagePencil - I'm usually a TypeScript dev these days and I work with VSCode on a daily basis. Having a similar dev environment would be excellent. Do you have any instructions for getting setup for SMS dev on VSCode?
  View user's profile Send private message
  • Joined: 23 Aug 2005
  • Posts: 31
  • Location: UK
Reply with quote
Instructions?
Post Posted: Fri Dec 27, 2019 5:55 pm
SavagePencil wrote
I’m doing all my dev in VSCode and that’s x-platform and way nicer than ConText + batch files. So yeah, it could use an update.


Do you have any tutorial or can overview how you have this set up? I'd be most interested to have a similar setup :)
  View user's profile Send private message
  • Joined: 23 Aug 2009
  • Posts: 113
  • Location: Seattle, WA
Reply with quote
Post Posted: Sat Dec 28, 2019 1:11 am
Blaghhh yeh I’ll post something tomorrow.

You can get a sneak peek at the environment here:

https://github.com/SavagePencil/SMSSampleApp?files=1
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 13144
  • Location: London
Reply with quote
Post Posted: Sat Dec 28, 2019 8:00 am
Personally I’ve dropped ConTEXT and moved to Notepad++. I’ve found the “modern” editors too slow for my common use case of 10MB+ disassemblies, but haven’t tried VSCode specifically.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2009
  • Posts: 113
  • Location: Seattle, WA
Reply with quote
Post Posted: Sat Dec 28, 2019 6:23 pm
I like the flexibility of project management, git integration, and being able to launch the assembler and emulator all from the IDE. I've written up my notes on how to do that here.
  View user's profile Send private message
  • Joined: 08 Sep 2018
  • Posts: 227
Reply with quote
Post Posted: Sat Dec 28, 2019 8:09 pm
I actually found ConTEXT easy to setup, though Notepad++ is too. I always struggle to set up other dev environments like SGDK. Though there is a nice web based IDE at 8bitworkshop that looks promising and easy to use. IDK how far you can go with it just yet though.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2622
Reply with quote
Post Posted: Sat Dec 28, 2019 8:47 pm
I use Geany (C development) or Eclipse (asm development) with efry's z80editor plugin.

Geany is quite good. Approach is quite similar to ConTEXT.
Eclipse... well, I hate that, but efry plugin is the reason why I'm using it.
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2005
  • Posts: 31
  • Location: UK
Reply with quote
Visual Studio Code
Post Posted: Mon Jan 13, 2020 4:49 pm
I headed over to the SMSDevKit, as I thought perhaps in the mean-time I'd look at programming in C. Got a great response there and I thought that response might be useful here: https://github.com/sverx/devkitSMS/issues/12

I have since setup a C environment in Visual Studio Code and tonight I will attempt to compile the sources from: https://www.smspower.org/Homebrew/AstroForce-SMS

Many thanks for the comments.

  View user's profile Send private message
  • Joined: 05 Dec 2019
  • Posts: 20
Reply with quote
Post Posted: Wed Feb 05, 2020 2:15 am
In particular, one tutorial I'd like to see is a worked example of how to design an actor struct such that its fields can be stepped through sequentially with HL. This way I wouldn't have to do random access through slow (IX+5) all the time. It seems all the 8080-family programming tutorials that I've seen stop before they get to this point.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2622
Reply with quote
Post Posted: Thu Feb 13, 2020 3:43 pm
well you could have actors variables at 256-byte aligned address, so you would do

ld h,>actor
ld l,member
ld a,(hl)


instead of

ld ix,actor
ld a,(ix+member)


and to access next member, if you organized them in convenient way, you just increment L instead of HL

there are caveats of course, but that's surely quicker
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2009
  • Posts: 113
  • Location: Seattle, WA
Reply with quote
Post Posted: Thu Feb 13, 2020 4:00 pm
...and if you have your actor members in a struct, you can easily do this (even if it may not be optimal):


.STRUCT sActor
    XPos        DB
    YPos        DB
    HitPoints   DW
.ENDST

; Put this in a RAM section to pre-alloc 4 bytes of the sActor struct.
.DSTRUCT MyActor INSTANCEOF sActor

ld hl, MyActor
.REPT sActor.HitPoints
    inc hl
.ENDR


(you could get fancy and find the break-evens for when it's better to add hl, de vs inc hl)
  View user's profile Send private message
  • Joined: 05 Dec 2019
  • Posts: 20
Reply with quote
Post Posted: Wed Feb 19, 2020 4:20 am
One of my current NES projects has 21 bytes per actor of striped state tables, which would be equivalent to the following struct:
.STRUCT sActor
    XVel        DW  ; in pixels per 256 frames
    XSubpx      DB  ; subpixel component of position
    XPos        DW  ; pixel and "screen" component of position
    YVel        DW
    YSubpx      DB
    YPos        DW
    ClassID     DB  ; determines which move routine to call
    AnimFrame   DB
    FrameTimer  DB
    StunTimer   DB  ; time until hitstun expires
    FaceDir     DB
    HitPoints   DB
    DamageHt    DB  ; height at which it most recently took damage
    CollideHt   DB  ; height of hurtbox
    CollideBits DB  ; some states temporarily disable hit/hurtbox
    Strength    DB  ; number of hit points removed from player on collision
    VramBase    DB
.ENDST

For a struct this big, I imagine access would fall fairly regularly on the add hl, de side of the break-even point unless the fields can somehow be optimally ordered. How would one go about determining this optimal ordering in advance?

A memory layout following the paradigm suggested by sverx would use 21 bytes of each 256-byte page for the actor struct and (256 - 21) = 235 bytes for something else. What support is there in the assembler or in any other tool for divvying up that something else?
  View user's profile Send private message
  • Joined: 04 Jul 2010
  • Posts: 274
  • Location: Angers, France
Reply with quote
Post Posted: Wed Feb 19, 2020 6:53 am
Some of my actors are bigger than that.
Try to round it up (to 8,16, 32, 64), align datas in ram for a faster access or modifications.

Sometimes it's better to use (ix+n) that add hl, de.

You can try to place posy, posx and meta (in this order) as they are needed to be pushed in the SAT.
  View user's profile Send private message
  • Joined: 05 Sep 2013
  • Posts: 2622
Reply with quote
Post Posted: Wed Feb 19, 2020 2:03 pm
PinoBatch wrote
A memory layout following the paradigm suggested by sverx would use 21 bytes of each 256-byte page for the actor struct and (256 - 21) = 235 bytes for something else. What support is there in the assembler or in any other tool for divvying up that something else?


in WLA-DX you can use 256-byte aligned free ramsections for the former and regular (unaligned) free ramsections for the latter
  View user's profile Send private message Visit poster's website
  • Joined: 23 Aug 2009
  • Posts: 113
  • Location: Seattle, WA
Reply with quote
Post Posted: Wed Feb 19, 2020 4:31 pm
PinoBatch wrote

For a struct this big, I imagine access would fall fairly regularly on the add hl, de side of the break-even point unless the fields can somehow be optimally ordered. How would one go about determining this optimal ordering in advance?


I haven't tried it myself, but I bet you could do something along the lines of:


.IF sActor.myMember > 5 ;Or whatever the break-even point between inc and add hl, de is
    ld de, sActor.myMember
    add hl, de
.ELSE
    .REPT sActor.myMember
        inc hl
    .ENDR
.ENDIF


Not sure if you could .MACRO this.
  View user's profile Send private message
Reply to topic



Back to the top of this page

Back to SMS Power!