009
05.10.2012, 09:00 Uhr
PeterSieg
|
Danke für die sehr hilfreichen Tips! Diese und etwas googeln brachten nun eine erste lauffähige Version:
Quellcode: | ; Programm ;------------------------------------------------------------------------------ ; Start auf Adr. 1000 (Zusatz-ROM 3) ;------------------------------------------------------------------------------
CPU Z80 ; include lc80-2x1 ;2x1k Rom U505 include lc80-1x2 ;1x2k Rom 2716
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ org 1000h ld a,R ; read refresh register as seed ld l,a ; in to reg a jp nz,seed2 ; if not zero continue ld l,3 ; else set to 3 seed2: push hl ; seed on stack main: ;------------------------------------------------------------------------------ ; generate random index value ;------------------------------------------------------------------------------
pop hl ; L = alte Zufallszahl
LD A,L AND 08EH ; RKM L JP PE,S1 CCF S1: RL L ; L = neue Zufallszahl push hl ; save on stack
ld a,l and a,7 ; just 8 values 0-7 ld l,a ld h,0
;------------------------------------------------------------------------------ ; multiply by 6 since our words array is fixed length on 6 bytes ;------------------------------------------------------------------------------
add hl,hl ; HL = Index * 2 ld d,h ; DE = Index * 2 ld e,l add hl,hl ; HL = Index * 4 add hl,de ; HL = Index * 6
;------------------------------------------------------------------------------ ; now point to start of words array and add index value times 6 (element length) ;------------------------------------------------------------------------------
ld de,words0 ; start of array address add hl,de ; HL = ArrayAddress + Index * 6
;------------------------------------------------------------------------------ ; just get hl into ix for subroutine dak2 ;------------------------------------------------------------------------------
push hl ; hl on stack pop ix ; get hl as ix from stack
ld e,200 ; delay value char w0: call dak2 call delay1 dec e jp nz,w0 ; times e jp main
;------------------------------------------------------------------------------ ; simle delay routine of 256 nop's ;------------------------------------------------------------------------------
delay1: ld a,0 ; 256 x NOP; A is destroyed del11: nop inc a jp nz,del11 del12: ret
;------------------------------------------------------------------------------ ; our array of words in LC80 7-segment byte values ;------------------------------------------------------------------------------ words0: db 000h,000h,000h,0cah,0aeh,021h ;"1ST " db 000h,000h,000h,0e9h,068h,0cdh ;"2ND " db 000h,000h,000h,0ceh,0eah,0cdh ;"2BE " db 000h,000h,000h,0e8h,0e9h,0cdh ;"2DO " db 000h,000h,0ceh,020h,0e9h,0cdh ;"2DIE " db 000h,000h,0c2h,0c2h,06fh,02bh ;"4ALL " db 000h,06bh,0cah,048h,06fh,0ceh ;"EARTH " db 000h,000h,0ceh,04fh,0e8h,06bh ;"HOPE "
;------------------------------------------------------------------------------
end
|
Natürlich noch mit sicher viel Verbesserungspotential..
Peter Dieser Beitrag wurde am 05.10.2012 um 09:50 Uhr von PeterSieg editiert. |