A little help for a simple machine code program.
Posted: Mon Jul 29, 2013 6:16 pm
I am trying to write a simple machine code routine.
I want that program to scan hires screen memory to look for a color byte and change it to another.
I mean, for example, it scans for "1" value in HIRES memory and change all the "1"s to "4" . So in the picture, all the red parts turns to the blue.
Here's the code I wrote but it does not work. AgAin I am not good at assemble monitors or C. I write machine code programs under basic by entering hex codes. So I will give hex codes and try to explain what I ment to with equivalent BASIC tokens.
'DOKE 2,#A000 --> BEGINNING OF HIRES
$1000 A9 00 LDA #$00
$1002 85 02 STA $02
$1004 A9 A0 LDA #$A0
$1006 85 03 STA $03
'DOKE 4,#1F40 ----> Size of hires - 8000 bytes
$1008 A9 40 LDA #$40
$100A 85 04 STA $04
$100C A9 1F LDA #$1F
$100E 85 05 STA $05
'Y=0: A=PEEK(DEEK(2))+Y
$1010 A0 00 LDY #$00
$1012 B1 02 LDA ($02),Y
'IF A=PEEK(0) THEN POKE A,PEEK(1)
$1014 C5 00 CMP $00
$1016 D0 04 BNE $101C
$1018 A5 01 LDA $01
$101A 91 02 STA ($02),Y
'DOKE 2,DEEK(2)+1
$101C 18 CLC
$101D E6 02 INC $02
$101F D0 02 BNE $1023
$1021 E6 03 INC $03
'DOKE 4,DEEK (4)-1
$1023 C6 04 DEC $04
$1025 A5 04 LDA $04
$1027 C9 FF CMP #$FF
$1029 C6 05 DEC $05
'IF DEEK (4) > 0 THEN GOTO $1010
$102B D0 E3 BNE $1010
$102D 60 RTS
My program is like that. It is supposed to look for memory location 0 and change every byte in HIRES which is the same as PEEK(0) TO PEEK(1)
So I do this but nothing changes . It immediately says ready.
POKE 0,1:POKE 1,4 : CALL#1000
I might have errors in branchings and increasing and decreasing the memories.
Can you check and tell me what is wrong?
Or you might suggest easier way to search for a memory and change it like that.
Thank you very much .
I want that program to scan hires screen memory to look for a color byte and change it to another.
I mean, for example, it scans for "1" value in HIRES memory and change all the "1"s to "4" . So in the picture, all the red parts turns to the blue.
Here's the code I wrote but it does not work. AgAin I am not good at assemble monitors or C. I write machine code programs under basic by entering hex codes. So I will give hex codes and try to explain what I ment to with equivalent BASIC tokens.
'DOKE 2,#A000 --> BEGINNING OF HIRES
$1000 A9 00 LDA #$00
$1002 85 02 STA $02
$1004 A9 A0 LDA #$A0
$1006 85 03 STA $03
'DOKE 4,#1F40 ----> Size of hires - 8000 bytes
$1008 A9 40 LDA #$40
$100A 85 04 STA $04
$100C A9 1F LDA #$1F
$100E 85 05 STA $05
'Y=0: A=PEEK(DEEK(2))+Y
$1010 A0 00 LDY #$00
$1012 B1 02 LDA ($02),Y
'IF A=PEEK(0) THEN POKE A,PEEK(1)
$1014 C5 00 CMP $00
$1016 D0 04 BNE $101C
$1018 A5 01 LDA $01
$101A 91 02 STA ($02),Y
'DOKE 2,DEEK(2)+1
$101C 18 CLC
$101D E6 02 INC $02
$101F D0 02 BNE $1023
$1021 E6 03 INC $03
'DOKE 4,DEEK (4)-1
$1023 C6 04 DEC $04
$1025 A5 04 LDA $04
$1027 C9 FF CMP #$FF
$1029 C6 05 DEC $05
'IF DEEK (4) > 0 THEN GOTO $1010
$102B D0 E3 BNE $1010
$102D 60 RTS
My program is like that. It is supposed to look for memory location 0 and change every byte in HIRES which is the same as PEEK(0) TO PEEK(1)
So I do this but nothing changes . It immediately says ready.
POKE 0,1:POKE 1,4 : CALL#1000
I might have errors in branchings and increasing and decreasing the memories.
Can you check and tell me what is wrong?
Or you might suggest easier way to search for a memory and change it like that.
Thank you very much .