Suggestions on formatting of code

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Joefish
Manic Miner
Posts: 839
Joined: Tue Nov 14, 2017 10:26 am

Re: Suggestions on formatting of code

Post by Joefish »

Morkin wrote:
Fri Jul 03, 2020 11:59 am
Joefish wrote:
Fri Jul 03, 2020 10:37 am
Also define stuff like WAIT_VBL as EI followed by HALT.
...Isn't that more keystrokes?
Yes, by one, but it's also an easy way to remember to do an EI before a HALT where your design needs it so you don't deliberately hang your own code.
0 x

User avatar
Cosmium
Dizzy
Posts: 76
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: Suggestions on formatting of code

Post by Cosmium »

Joefish wrote:
Fri Jul 03, 2020 10:37 am
I also include a file of macros that defines things like SCREEN EQU 16384, and also JPEQ, JPGE and JPLT to use instead of jp nz, jp nc or jp c following a 'compare' as I can never remember which way round to use the last two.
That's a bit like the perpetually cryptic (to me at least!) RRCA and RRA etc. I can never can remember which one does what with the carry and always have to look it up. Maybe some macros to clearly differentiate these would be helpful to? :)
0 x

User avatar
Einar Saukas
Dynamite Dan
Posts: 1303
Joined: Wed Nov 15, 2017 2:48 pm

Re: Suggestions on formatting of code

Post by Einar Saukas »

Cosmium wrote:
Sat Jul 04, 2020 2:30 am
That's a bit like the perpetually cryptic (to me at least!) RRCA and RRA etc. I can never can remember which one does what with the carry and always have to look it up.
I could never remember it either, that's one of the reasons I did this:

https://www.ime.usp.br/~einar/z80table/index.html

Click on "MISC" at the bottom of that page.
2 x

User avatar
ketmar
Microbot
Posts: 167
Joined: Tue Jun 16, 2020 5:25 pm

Re: Suggestions on formatting of code

Post by ketmar »

as we started talking about remembering commands... i'm often looking into Zymosis code to remember details on some instructions. there cannot be a better reference than a working Z80 emulator! ;-)
0 x

Joefish
Manic Miner
Posts: 839
Joined: Tue Nov 14, 2017 10:26 am

Re: Suggestions on formatting of code

Post by Joefish »

Good point. I might add RR8 and RR9 to my macros file to remember how many bits are used, as I think RR and RRC are defined the wrong way round.
0 x

User avatar
Ast A. Moore
Dynamite Dan
Posts: 1684
Joined: Mon Nov 13, 2017 3:16 pm

Re: Suggestions on formatting of code

Post by Ast A. Moore »

. . . to say nothing of the logical and arithmetic shifts. ;)
0 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

User avatar
utz
Dizzy
Posts: 87
Joined: Wed Nov 15, 2017 9:04 am
Contact:

Re: Suggestions on formatting of code

Post by utz »

A round of appreciation for Einar's z80table! Opening that up is pretty much always my first action when doing any serious Z80 coding.
1 x

User avatar
Ast A. Moore
Dynamite Dan
Posts: 1684
Joined: Mon Nov 13, 2017 3:16 pm

Re: Suggestions on formatting of code

Post by Ast A. Moore »

I use a copy an offline copy of this. I made a few corrections to it.
2 x
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.

XoRRoX
Dizzy
Posts: 52
Joined: Wed Jul 11, 2018 6:34 am

Re: Suggestions on formatting of code

Post by XoRRoX »

Nice to see everyone's approach.

I'm putting labels on a separate line to be more flexible with using descriptive names.

Code: Select all

	call clearPlayArea

announceLvl2:
	xor a
	ld (flagSkipSegment),a
0 x

User avatar
Morkin
Manic Miner
Posts: 998
Joined: Mon Nov 13, 2017 8:50 am
Location: Bristol, UK

Re: Suggestions on formatting of code

Post by Morkin »

XoRRoX wrote:
Sun Jul 05, 2020 9:46 pm
Nice to see everyone's approach.

I'm putting labels on a separate line to be more flexible with using descriptive names.

Code: Select all

	call clearPlayArea

announceLvl2:
	xor a
	ld (flagSkipSegment),a
andydansby wrote:
Thu Jul 02, 2020 5:57 pm
My preference has been for camelCase, just easier on my eyes.
...So just out of interest (for someone who doesn't do a lot of 'modern' development), what is it about camel case that you like/prefer?

Or is it a habit thing that's been learned (e.g. Javascript)?
0 x

Post Reply