; Memory test routine 16427 ld hl,0 ; clear HL 16430 add hl,sp ; Add the stack pointer (apparently, this brings up HL to what would be STKEND on ZX81/Spectrum) 16431 ld de,(16396) ; Now need to "PEEK_W" 16393 and subtract it from HL 16435 and a ; clear flags 16436 sbc hl,de ; subtract "PEEK_W" 16396 from HL 16438 ld b,h ; Put HL into BC 16439 ld c,l 16440 ret ; PRINT USR(16427) returns number of bytes remaining ; Alphabet scrambler routine 16441 ld b,255 ; run this process 255 times 16443 push bc ; store the initial loop variable on the stack – the RNG will overwrite it 16444 J1: ld hl,15 ; tell the RNG we want a number between 1 and the value we put into HL, i.e. 15 16447 call 3053 ; CALL the RNG from the ROM. BC now stores one less than the value in HL, i.e. random number between 0 and 14 16450 ld hl,16542 ; put address of SECOND character in the line 2 REM statement into HL; this is the character that will be chosen if BC=0, and the 16th character will be chosen if BC=14 16453 add hl,bc ; HL is now set to the address of the randomly selected character we want to move 16454 ld a,(hl) ; store the character to be moved in a free register – A is ideal 16455 ld b,c ; the value of BC is stored only in C (i.e. B=0) and we need to move the character to the left (C+1) times to get it to the start of the sequence – so put the value of C into B... 16456 inc b ; ...then add 1 and B now stores the number of times we need to perform the next loop. 16457 J2: dec hl ; each iteration of this loop performs "LD HL,(HL-1)". Move HL back one to point at the previous character 16458 ld c,(hl) ; C is now free to use. Load the new contents of where HL is pointing into C 16459 inc hl ; Move HL up one to where it started 16460 ld (hl),c ; and drop the contents of C into this new location. 16461 dec hl ; Move HL back one again so it's pointing to the correct address for the next iteration. 16462 djnz M2 ; jump back to marker J2 until we're finished with this process 16464 ld (hl),a ; HL is now pointing to the first address in the REM statement after the loop; fill it with the character we originally selected 16465 pop bc ; get the first loop variable back from the stack 16466 djnz M1 ; jump back to marker J1 until this process is finished 16468 ret ; done! ; Tim Hartnell's Amazing Active Display (corrected by Paul Farrow) ; Tim was much better at machine code than I will ever be, so there are not many notes on this! 16469 call 1760 16472 call 1474 16475 ld bc,288 16478 exx 16479 call 1474 16482 T1: jr T2 16484 call 429 16487 T2: ld b,8 16489 T3: djnz T3 16491 ld hl,(16414) ; the ZX80's (two-byte) equivalent of FRAMES on the ZX81 (which used three bytes) 16494 inc hl 16495 ld (16414),hl 16498 ld a,h 16499 sbc a,0 16501 ret z 16502 inc hl 16503 in a,(254) 16505 ld a,56 16507 ld (16419),a ; the high byte of "value of the last expression or variable"... 16510 ld b,94 16512 T4: djnz T4 16514 out (254),a 16516 ld a,236 16518 ld b,25 16520 ld hl,(16396) ; the ZX80's D_FILE 16523 set 7,h 16525 call 429 16528 ld a,245 16530 inc b 16531 dec hl 16532 inc iy 16534 inc hl 16535 jr T1