Andreas Gustafsson's Blog

Monday, March 12, 2012

How a piece of cardboard can improve loading...

I guess I have to stop spamming my blog with so much posts, not even three years have passed since last time, but you will have to try to keep up! ;)

Let's start with the resolution to the ever-so-exciting question of what the code snippet in the last post about Z80 optimizing was:

The answer is the bumpmapper right at the start of this MSX demo!

And now on to other Z80-related stuff. I recently bought a ZX Sinclair +2A, and now I'm trying to finish a demo in time for the Forever party later this week.

I was having a bit of trouble with loading my stuff today though. The +2A doesn't have an external cassette port, so I load from the built in one using one of those crappy MP3-car-cassette adapters. However, it stopped working. After some experimentation I came up with this somewhat MacGyverish solution:



The central thing here is the piece of cardboard wedged down above the play button. It presses just enough on the button that the adapter makes contact with the tape head in the Spectrum, but not too much that the motor starts running (because then it would just stop loading entirely after a while). Empirical studies showed that three layers of cardboard was the sweet spot, two didn't press enough to give contact with the head while four made the motor start.
Sometimes you just got to love old hardware!

Labels: , , ,

Thursday, August 13, 2009

Z80 optimizing

It's funny how you can look at some code and think, yeah, that's as good as it gets, then suddenly you get a bright idea and realize that - no, it wasn't!
I am working on yet another little demo at the moment, on a system that uses the Z80 CPU (not saying any more than that at the moment! :))
For one of the effects, a single iteration of an unrolled loop looked like this:

exx ; 4
ld a,(bc) ; 7
inc bc ; 6
ld l,a ; 4
ld d,(hl) ; 7
ld a,(bc) ; 7
inc bc ; 6
ld l,a ; 4
ld a,(hl) ; 7
sla a ; 8
or d ; 4
exx ; 4
ld (de),a ; 7
inc de ; 6
---
81 T-STATES

That was my first, off-the-top-of-my-head implementation made a couple of days ago. I was convinced that it was possible to do much better, but I couldn't figure anything out.

Then yesterday I made some progress and came up with this, by swapping around some registers and realizing that in this case rlca worked just as well as sla a and saved 4 T-states:

exx ; 4
ld c,(hl) ; 7
inc hl ; 6
ld a,(bc) ; 7
ld d,a ; 4
ld c,(hl) ; 7
inc hl ; 6
ld a,(bc) ; 7
rlca ; 4
or d ; 4
exx ; 4
ld (de),a ; 7
inc de ; 6
---
73 T-STATES

I sat and stared at the solution for a quite long, and thought, yeah, that's optimized!
But today I discovered that by rearranging my data and using the nice ex de,hl instruction, there were cycles to be saved, and I ended up with this:

ld e,(hl) 7
inc hl ; 6
ld a,(de) ; 7
rlca ; 4
ld e,(hl) 7
inc hl ; 6
ex de,hl ; 4
or (hl) ; 7
ex de,hl ; 4
ld (bc),a ; 7
inc bc ; 6
---
65 T-STATES


So NOW it must be as optimized as possible, right? :)

Labels: ,

Thursday, January 01, 2009

2008 in retrospect

Yes, my blog has been woefully neglected the past year, so I better start this year a bit more productively with a look back at 2008.

Major things for me during 2008 was first of all that I added several nice items to my collection of old 80ies computers:

  • Commodore Plus/4

  • Commodore VIC-20

  • Philips NMS-8245 (MSX2)

  • Atari 130XE

  • Commodore 64 (old bread-bin model, I had a C64C before)


I also had a very productive year on the demoscene (after a bit slow start the first months), releasing more stuff than I have ever done any previous year:

  • 407566 - C64 onefile demo, released in April

  • Very Much Useless - Sega VMU demo, winner of mixed compo at LCP2008 in August

  • Pseudocode - C64 demo, 3rd in C64 compo at LCP2008 in August

  • 126b - VIC-20 intro, released in August

  • Ancient School - VIC-20 demo, winner of Sundown oldschool demo competition in September

  • Invasion of the big pixels - MSX1 demo, 2nd place at the Grep White demo competition in December


I'll be very pleased if I can keep the same tempo this year!

Labels:

Monday, August 06, 2007

BFP 2007

A week has passed since the Big Floppy People 2007 demo party, and I have forgotten to write about it!

It was a nice event, and I got to chat with some cool people like Archmage/Andromeda (who showed me stome stuff he was working on for the ASD-demo that won ASM07 this weekend), Zzap69 (a former Noice-member I never met before), Fix/TRSI (a fellow DTV owner who was kind enough to let us use his machine in the compo when mine didn't cooperate with the bigscreen projector) and many others. Best of all, I won the mixed demo competition with my DTV-demo, Uncharted Territory!

Labels: ,

Friday, July 27, 2007

Mad crunchtime!

I've been in completely insane coding crunch mode for almost two weeks now trying to finish my new DTV demo in time for Big Floppy People 2007

The amount of boring work that goes into linking everything together, making sure that parts cooperate nicely etc. is mind-boggling to say the least. I think I've spent about as many hours now just with putting the parts together as I have actually coding the ffects.

Well, now I'm ALMOST there, still some minor bugs, but I'm so damn tired of this that I think I will consider it ready now! :)
Anyway, here's a sneak preview of the intropicture from the demo:





Release should be now on saturday if everything works out!

Labels: ,