A miracle when it works first time!

The place for codemasters or beginners to talk about programming any language for the Spectrum.
User avatar
R-Tape
Site Admin
Posts: 6402
Joined: Thu Nov 09, 2017 11:46 am

Re: A miracle when it works first time!

Post by R-Tape »

Image

Coding's coming along nicely.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: A miracle when it works first time!

Post by Ast A. Moore »

R-Tape wrote: Sun Apr 05, 2020 10:28 am Coding's coming along nicely.
Lovely.

Waiter! I’ll have what the gentleman’s having. :D
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
Cosmium
Microbot
Posts: 156
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: A miracle when it works first time!

Post by Cosmium »

Ast A. Moore wrote: Sun Apr 05, 2020 11:04 am Waiter! I’ll have what the gentleman’s having. :D
Of course sir. And perhaps for dessert..

Image

I had a little chuckle when a few straightforward (or so I thought) optimisations to sprite rendering resulted in this OTT crash! Still working on finding the bug :?
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2641
Joined: Mon Nov 13, 2017 3:16 pm

Re: A miracle when it works first time!

Post by Ast A. Moore »

Cosmium wrote: Sat Apr 11, 2020 8:06 am Of course sir. And perhaps for dessert..
Image
Oh, yeah . . . That hit the spot.
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
Cosmium
Microbot
Posts: 156
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: A miracle when it works first time!

Post by Cosmium »

Think I'd better beef up the safeguards for sprites writing outside of screen memory...

Image

as appears to have happened here. Man, what a show :lol:
User avatar
R-Tape
Site Admin
Posts: 6402
Joined: Thu Nov 09, 2017 11:46 am

Re: A miracle when it works first time!

Post by R-Tape »

Haha brill. How on earth did you get it to do that?!
Cosmium wrote: Sun May 10, 2020 11:28 pm Think I'd better beef up the safeguards for sprites writing outside of screen memory...
Never used to do safeguards, but a while back, I started checking that D was below 88 before any pixel draw subroutine, and if so doing a JP NC, safety, that sets DE to draw safely in ROM.
User avatar
Cosmium
Microbot
Posts: 156
Joined: Tue Dec 04, 2018 10:20 pm
Location: USA

Re: A miracle when it works first time!

Post by Cosmium »

R-Tape wrote: Mon May 11, 2020 12:08 am Haha brill. How on earth did you get it to do that?!
I know, it's a ridiculous display isn't it?! I'd been tinkering with adding a write address offset as sprite data was written to the screen. I already had a check to make sure y <= 191 but hadn't figured on encountering larger x offsets pushing the write address outside of screen memory.

I probably could've zeroed in on the source of the bug sooner using ZX SPIN disassembler's conditional breakpoints, but I haven't yet figured out the syntax to check for a write to an addresses range..

R-Tape wrote: Mon May 11, 2020 12:08 am Never used to do safeguards, but a while back, I started checking that D was below 88 before any pixel draw subroutine, and if so doing a JP NC, safety, that sets DE to draw safely in ROM.
That's a good plan too. It's always a toss up between speed and safety eh? Guess I've been leaning towards speed but it's catching me out occasionally when values go outside the range of initial expectations.

Probably a better approach is to add conditional assembly based on an EQU for a special "debug" build with these safeguards in place, which can be easily removed for performance in "release" code. Note to self: actually do this rather than talk about it as a theory!
User avatar
R-Tape
Site Admin
Posts: 6402
Joined: Thu Nov 09, 2017 11:46 am

Re: A miracle when it works first time!

Post by R-Tape »

One of my more unusual crashes:

Image

I think it was the speccy rebelling against Dave Spicer's cruelty to Z80 registers.
Post Reply