martinpiper / BDD6502

Behaviour Driven Development with 6502 code
27 stars 2 forks source link

Ozi upgrades1 #6

Closed oziphantom closed 8 years ago

oziphantom commented 8 years ago

Due to the differences in the machines I made this code on and compilers I will put the tests and features I used to test as comments for you to patch and fix up

oziphantom commented 8 years ago

since I had a Linux VM and I took Maven to be a Linux system I made this on linux which makes it hard to do the acme.exe. I did download the code for acme and make it but the !sal doesn't seem to be recognised by it. So here are the ASM files I used in my features

oziphantom commented 8 years ago

bin.asm used to make bin.bin ( don't get ACME to make a cbm format )

*=0
!byte 00,01,02,03,04,05,32
oziphantom commented 8 years ago

brk.prg

* = $810
lda #00
sta $d020
brk
lda #01
sta $d021
rts
oziphantom commented 8 years ago

runTillMemortEqual.prg

* = $810
LDX #0
LOOP
INX
DEC $1000
BNE LOOP
RTS
oziphantom commented 8 years ago

regState.prg

* = $810
LDA #0
LDX #0
LDY #0
JSR TEST2
RTS

TEST2 LDA #1
RTS
oziphantom commented 8 years ago

regState2.prg

* = $810
LDA #0
LDX #0
LDY #0
!byte 2,$12,$22
jsr TEST2
!byte $32,$42,$52
RTS

TEST2 LDA #1
LDX #1
LDY #1
!byte 2,$12,$22
!byte $32,$42,$52
LDA #0
LDX #0
LDY #0
RTS
oziphantom commented 8 years ago

joy,prg

* = $810
ldx #4
lda #0
loop
sta $1000,x
dex
bpl loop
ldx #1
lda $dc00
lsr 
bcc joyUp
lsr  
bcc joyDown
checkLR
lsr 
bcc joyLeft
lsr 
bcc joyRight
checkFire
lsr 
bcs joyEnd
stx $1004 ;joyFire
joyEnd
rts
joyUp
lsr 
stx $1000 ; joy up
jmp checkLR
joyDown
stx $1001 ; joy down
jmp checkLR
joyLeft
stx $1002 ; joy left
lsr 
jmp checkFire
joyRight
stx $1003 ; joy right
jmp checkFire
oziphantom commented 8 years ago

and the features

Feature: Test enable trace

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I load prg "regState.prg"
  And I enable trace
  And I set label START equal to $810
  When I execute the procedure at $810 for no more than 100 instructions
  Then I disable trace

Feature: Test the run till memory location equals

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I load prg "runTillMemoryEqual.prg"
  And I write memory at $1000 with 5
  When Until $1000 = 0 execute from $810
  Then I expect register x equal 5

Feature: Test register stack test A/X/Y

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I load prg "regState2.prg"
  When I execute the procedure at $810 for no more than 100 instructions

Scenario: Simple code test extra execution
  Given I have a simple 6502 system
  And I load prg "regState2.prg"
  When I execute the procedure at $810 for no more than 100 instructions
  And I execute the procedure at $810 for no more than 100 instructions
  And I execute the procedure at $820 for no more than 100 instructions

Feature: Test register stack push/pop doesn't break flow

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I load prg "regState.prg"
  When I execute the procedure at $810 for no more than 100 instructions

Feature: Test the less than and greater than test

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I write memory at $1000 with 5
  And I set register A to 32
  Then I expect register A to be less than 40
  And I expect register A to be greater than 30
  And I expect to see $1000 less than 10
  And I expect to see $1000 greater than 2

Feature: Test the joy input feature

  This assembles simple code and checks the expected results after executing it

Scenario Outline: Simple code test
  Given I have a simple 6502 system
  And I load prg "joy.prg"
  And Joystick 2 is <joy>
  When I execute the procedure at $810 for no more than 255 instructions
  And I expect to see $1000 equal <joy_up>
  And I expect to see $1001 equal <joy_down>
  And I expect to see $1002 equal <joy_left>
  And I expect to see $1003 equal <joy_right>
  And I expect to see $1004 equal <joy_fire>

Examples:
| joy    | joy_up | joy_down | joy_left | joy_right | joy_fire |
| NONE   | 0      | 0        | 0        | 0         | 0        |
| U      | 1      | 0        | 0        | 0         | 0        |
| D      | 0      | 1        | 0        | 0         | 0        |
| L      | 0      | 0        | 1        | 0         | 0        |
| R      | 0      | 0        | 0        | 1         | 0        |
| FIRE   | 0      | 0        | 0        | 0         | 1        |
| UFIRE  | 1      | 0        | 0        | 0         | 1        |
| ULFIRE | 1      | 0        | 1        | 0         | 1        |
| URFIRE | 1      | 0        | 0        | 1         | 1        |
| DFIRE  | 0      | 1        | 0        | 0         | 1        |
| DLFIRE | 0      | 1        | 1        | 0         | 1        |
| DRFIRE | 0      | 1        | 0        | 1         | 1        |
| LFIRE  | 0      | 0        | 1        | 0         | 1        |
| RFIRE  | 0      | 0        | 0        | 1         | 1        |

Feature: Test BRK Fail

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I load prg "brk.prg"
  And That does exit on BRK
  When I execute the procedure at $810 for no more than 100 instructions
  And I expect to see $D020 equal $00

Feature: Test the load bin file at feature

  This assembles simple code and checks the expected results after executing it

Scenario: Simple code test
  Given I have a simple 6502 system
  And I load bin "bin.bin" at $1000
  Then I expect to see $1000 contain 0
  And I expect to see $1001 contain 1
  And I expect to see $1002 contain 2
  And I expect to see $1003 contain 3
  And I expect to see $1004 contain 4
  And I expect to see $1005 contain 5
  And I expect to see $1006 contain 32
oziphantom commented 8 years ago

I should warn you I don't know JAVA ;) I'm a c/c++/c#/obj-c programmer, so there might be some weird stuff in there for Java. Since I could not run your build in test and because src/test/resources/test.lbl isn't checked in I wasn't able to run the build in java test as well.