Несколько найденных в интернетах кусков листинга. Лучше всего проверить, как работают примеры.
Печать текста на Atari
; compile with Atasm
;https://unfinishedbitness.info/2014/04/25/6502-displaying-text-finally/
;05 .OPT OBJ
*= $0600
; CIO
ICHID = $0340 ;IOCB 0 S:
ICCOM = $0342 ;IOCB Command
ICBAL = $0344 ;Xfer Buffer Adr
ICBAH = $0345
ICPTL = $0346 ;PutByte Adr
ICPTH = $0347
ICBLL = $0348 ;Buffer Len
ICBLH = $0349
CIOV = $E456 ; CIO Vector
; Setup CIO Call
LDX #0 ;IOCB 0
LDA #9 ;Put Cmd Val
STA ICCOM,X ;Set it as the cmd
LDA #HELLO&255 ;Str low byte
STA ICBAL,X
LDA #HELLO/256 ;Str high byte
STA ICBAH,X
LDA #0 ;Str Len low byte
STA ICBLL,X
LDA #$FF ;Str Len high byte
STA ICBLH,X
; Call CIO
JSR CIOV
; RTS
jmp *
HELLO .BYTE "Hello Atari!",$9B
;https://unfinishedbitness.info/2014/04/25/6502-displaying-text-finally/
;05 .OPT OBJ
*= $0600
; CIO
ICHID = $0340 ;IOCB 0 S:
ICCOM = $0342 ;IOCB Command
ICBAL = $0344 ;Xfer Buffer Adr
ICBAH = $0345
ICPTL = $0346 ;PutByte Adr
ICPTH = $0347
ICBLL = $0348 ;Buffer Len
ICBLH = $0349
CIOV = $E456 ; CIO Vector
; Setup CIO Call
LDX #0 ;IOCB 0
LDA #9 ;Put Cmd Val
STA ICCOM,X ;Set it as the cmd
LDA #HELLO&255 ;Str low byte
STA ICBAL,X
LDA #HELLO/256 ;Str high byte
STA ICBAH,X
LDA #0 ;Str Len low byte
STA ICBLL,X
LDA #$FF ;Str Len high byte
STA ICBLH,X
; Call CIO
JSR CIOV
; RTS
jmp *
HELLO .BYTE "Hello Atari!",$9B
Звуковой эффект ZX Spectrum(beeper)
device zxspectrum128
ORG #6000
begin
call noise
wk: xor a:in a,($FE) ; wait keypress
cpl
and 31
jr z,wk
jr begin
;https://chuntey.wordpress.com/2013/02/28/how-to-write-zx-spectrum-games-chapter-3/
;This routine is based on a sound effect from Egghead 3
noise ld e,250 ; repeat 250 times.
ld hl,0 ; start pointer in ROM.
noise2 push de
ld b,32 ; length of step.
noise0 push bc
ld a,(hl) ; next "random" number.
inc hl ; pointer.
and 248 ; we want a black border.
out (254),a ; write to speaker.
ld a,e ; as e gets smaller...
cpl ; ...we increase the delay.
noise1 dec a ; decrement loop counter.
jr nz,noise1 ; delay loop.
pop bc
djnz noise0 ; next step.
pop de
ld a,e
sub 24 ; size of step.
cp 30 ; end of range.
ret z
ret c
ld e,a
cpl
noise3 ld b,40 ; silent period.
noise4 djnz noise4
dec a
jr nz,noise3
jr noise2
end
display /d,end-begin
savesna "zxbeep.sna",begin
ORG #6000
begin
call noise
wk: xor a:in a,($FE) ; wait keypress
cpl
and 31
jr z,wk
jr begin
;https://chuntey.wordpress.com/2013/02/28/how-to-write-zx-spectrum-games-chapter-3/
;This routine is based on a sound effect from Egghead 3
noise ld e,250 ; repeat 250 times.
ld hl,0 ; start pointer in ROM.
noise2 push de
ld b,32 ; length of step.
noise0 push bc
ld a,(hl) ; next "random" number.
inc hl ; pointer.
and 248 ; we want a black border.
out (254),a ; write to speaker.
ld a,e ; as e gets smaller...
cpl ; ...we increase the delay.
noise1 dec a ; decrement loop counter.
jr nz,noise1 ; delay loop.
pop bc
djnz noise0 ; next step.
pop de
ld a,e
sub 24 ; size of step.
cp 30 ; end of range.
ret z
ret c
ld e,a
cpl
noise3 ld b,40 ; silent period.
noise4 djnz noise4
dec a
jr nz,noise3
jr noise2
end
display /d,end-begin
savesna "zxbeep.sna",begin

Комментарии
Отправить комментарий