Top Level Namespace
- Includes:
- Asm6502
Defined Under Namespace
Modules: Asm6502
Constant Summary collapse
- TIA_BASE_ADDRESS =
0- TIA_BASE_READ_ADDRESS =
TIA_BASE_ADDRESS- TIA_BASE_WRITE_ADDRESS =
TIA_BASE_ADDRESS- VERSION_MACRO =
MACRO.H Version 1.06, 3/SEPTEMBER/2004
106
Instance Method Summary collapse
-
#clean_start ⇒ Object
——————————————————————————- CLEAN_START Original author: Andrew Davie Standardised start-up code, clears stack, all TIA registers and RAM to 0 Sets stack pointer to $FF, and all registers to 0 Sets decimal mode off, sets interrupt flag (kind of un-necessary) Use as very first section of code on boot (ie: at reset) Code written to minimise total ROM usage - uses weird 6502 knowledge :).
-
#set_pointer(pointer, address) ⇒ Object
——————————————————- SET_POINTER Original author: Manuel Rotschkar.
-
#sleep(cycles) ⇒ Object
——————————————————————————- SLEEP duration Original author: Thomas Jentzsch Inserts code which takes the specified number of cycles to execute.
-
#vertical_sync ⇒ Object
OUT: A = 0.
Instance Method Details
#clean_start ⇒ Object
CLEAN_START Original author: Andrew Davie Standardised start-up code, clears stack, all TIA registers and RAM to 0 Sets stack pointer to $FF, and all registers to 0 Sets decimal mode off, sets interrupt flag (kind of un-necessary) Use as very first section of code on boot (ie: at reset) Code written to minimise total ROM usage - uses weird 6502 knowledge :)
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/asm6502/vcs/macro.rb', line 100 def clean_start sei cld ldx 0 txa tay Label[:CLEAR_STACK] dex txs pha bne :CLEAR_STACK # SP=$FF, X = A = Y = 0 end |
#set_pointer(pointer, address) ⇒ Object
SET_POINTER Original author: Manuel Rotschkar
Sets a 2 byte RAM pointer to an absolute address.
Usage: SET_POINTER pointer, address Example: SET_POINTER SpritePTR, SpriteData
Note: Alters the accumulator, NZ flags IN 1: 2 byte RAM location reserved for pointer IN 2: absolute address
128 129 130 131 132 133 |
# File 'lib/asm6502/vcs/macro.rb', line 128 def set_pointer(pointer, address) LDA #<.ADDRESS # Get Lowbyte of Address STA .POINTER # Store in pointer LDA #>.ADDRESS # Get Hibyte of Address STA .POINTER+1 # Store in pointer+1 end |
#sleep(cycles) ⇒ Object
SLEEP duration Original author: Thomas Jentzsch Inserts code which takes the specified number of cycles to execute. This is useful for code where precise timing is required. ILLEGAL-OPCODE VERSION DOES NOT AFFECT FLAGS OR REGISTERS. LEGAL OPCODE VERSION MAY AFFECT FLAGS Uses illegal opcode (DASM 2.20.01 onwards).
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/asm6502/vcs/macro.rb', line 56 def sleep(cycles) #usage: sleep n (n>1) if cycles < 2 puts "MACRO ERROR: 'SLEEP': Duration must be > 1" exit 1 end if cycles & 1 bit :VSYNC end cycles -= 3 (cycles / 2).times do nop end end |
#vertical_sync ⇒ Object
OUT: A = 0
81 82 83 84 85 86 87 88 89 |
# File 'lib/asm6502/vcs/macro.rb', line 81 def vertical_sync lda 0b1110 #%1110 # each '1' bits generate a VSYNC ON line (bits 1..3) Label[:VSLP1] sta :WSYNC # 1st '0' bit resets Vsync, 2nd '0' bit exit loop sta :VSYNC lsr bne :VSLP1 # branch until VYSNC has been reset end |