shutterbug2000
New member
Thanks for the advice GamerCat! I've downloaded the cpu manual, is there any other resources you recommend?
Thanks!
~shutterbug2000~
Thanks!
~shutterbug2000~
sub_200:
jp sub_225
data_202:
.byte 0x53
.byte 0x50
.byte 0x41
.byte 0x43
.byte 0x45
.byte 0x20
.byte 0x49
.byte 0x4E
.byte 0x56
.byte 0x41
.byte 0x44
.byte 0x45
.byte 0x52
.byte 0x53
.byte 0x20
.byte 0x30
.byte 0x2E
.byte 0x39
.byte 0x31
.byte 0x20
.byte 0x42
.byte 0x79
.byte 0x20
.byte 0x44
.byte 0x61
.byte 0x76
.byte 0x69
.byte 0x64
.byte 0x20
.byte 0x57
.byte 0x49
.byte 0x4E
.byte 0x54
.byte 0x45
.byte 0x52
sub_225:
ld v0, 0x00
ld v1, 0x00
ld v2, 0x08
ld i, data_3DD
sub_22D:
drw v0, v1, 0x8
add v1, 0x08
add i, v2
se v1, 0x20
jp sub_22D
add v0, 0x08
ld v1, 0x00
se v0, 0x40
jp sub_22D
ld v9, 0x05
ld vC, 0x15
ld vE, 0x00
sub_245:
call sub_391
ld v0, 0x0A
ld dt, v0
sub_24B:
ld v0, dt
se v0, 0x00
jp sub_24B
call sub_391
add vE, 0x01
jp sub_245
sub_257:
ld v6, 0x00
ld v8, 0x1C
ld v9, 0x00
ld vA, 0x04
ld vB, 0x0A
ld vC, 0x04
ld vD, 0x3C
ld vE, 0x0F
cls
call sub_375
call sub_351
ld dt, vD
sub_26F:
ld v0, 0x04
skp v0
jp sub_27D
data_275:
.byte 0x23
.byte 0x75
.byte 0x38
.byte 0x00
.byte 0x78
.byte 0xFF
.byte 0x23
.byte 0x75
sub_27D:
ld v0, 0x06
skp v0
jp sub_28B
data_283:
.byte 0x23
.byte 0x75
.byte 0x38
.byte 0x39
.byte 0x78
.byte 0x01
.byte 0x23
.byte 0x75
sub_28B:
se v6, 0x00
jp sub_29F
ld v0, 0x05
skp v0
jp sub_2E9
data_295:
.byte 0x66
.byte 0x01
.byte 0x65
.byte 0x1B
.byte 0x84
.byte 0x80
.byte 0xA3
.byte 0xD9
.byte 0xD4
.byte 0x51
sub_29F:
ld i, data_3D9
drw v4, v5, 0x1
add v5, 0xFF
se v5, 0xFF
jp sub_2AD
ld v6, 0x00
jp sub_2E9
sub_2AD:
drw v4, v5, 0x1
se vF, 0x01
jp sub_2E9
drw v4, v5, 0x1
ld v6, 0x00
ld v3, v4
add v3, 0x03
sub v3, vB
ld v2, 0xF8
and v3, v2
ld v2, 0x08
se v3, 0x00
jp sub_2C9
call sub_37D
sub_2C9:
shr v2, {, vX}
sne v3, 0x08
jp sub_2D3
se v3, 0x10
jp sub_2D5
sub_2D3:
call sub_37D
sub_2D5:
shr v2, {, vX}
se v3, 0x18
jp sub_2DD
call sub_37D
sub_2DD:
shr v2, {, vX}
sne v3, 0x20
jp sub_2E7
se v3, 0x28
jp sub_2E9
sub_2E7:
call sub_37D
sub_2E9:
se vE, 0x00
jp sub_307
add v9, 0x06
sne v9, 0x18
ld v9, 0x00
ld vA, 0x04
ld vB, 0x0A
ld vC, 0x04
add vD, 0xF4
ld vE, 0x0F
cls
call sub_351
call sub_375
ld dt, vD
jp sub_26F
sub_307:
ld v7, dt
se v7, 0x00
jp sub_26F
ld dt, vD
call sub_351
add vB, vA
se vB, 0x12
jp sub_31B
add vC, 0x02
ld vA, 0xFC
sub_31B:
se vB, 0x02
jp sub_323
add vC, 0x02
ld vA, 0x04
sub_323:
call sub_351
se vC, 0x18
jp sub_26F
cls
ld i, data_4DD
ld v0, 0x14
ld v1, 0x08
ld v2, 0x0F
sub_333:
drw v0, v1, 0xF
add v0, 0x08
add i, v2
se v0, 0x2C
jp sub_333
ld v0, 0xFF
ld dt, v0
sub_341:
ld v0, dt
se v0, 0x00
jp sub_341
ld v0, k
cls
ld i, data_706
ld vE, [i]
jp sub_225
sub_351:
ld i, data_3C1
add i, v9
ld v1, 0x08
call sub_369
shr v1, {, vX}
call sub_369
shr v1, {, vX}
call sub_369
shr v1, {, vX}
call sub_369
add vB, 0xD0
ret
sub_369:
ld v0, vE
and v0, v1
se v0, 0x00
drw vB, vC, 0x6
add vB, 0x0C
ret
sub_375:
ld i, data_3D9
ld v0, 0x1C
drw v8, v0, 0x4
ret
sub_37D:
call sub_351
xor vE, v2
call sub_351
ld v0, 0x05
ld st, v0
ld dt, v0
sub_389:
ld v0, dt
se v0, 0x00
jp sub_389
ret
sub_391:
ld vA, 0x00
ld vD, vE
ld vB, 0x04
sknp v9
jp sub_257
data_39B:
.byte 0xA6
.byte 0x0C
.byte 0xFD
.byte 0x1E
.byte 0xF0
.byte 0x65
.byte 0x30
.byte 0xFF
.byte 0x13
.byte 0xAF
.byte 0x6A
.byte 0x00
.byte 0x6B
.byte 0x04
.byte 0x6D
.byte 0x01
.byte 0x6E
.byte 0x01
.byte 0x13
.byte 0x97
.byte 0xA5
.byte 0x0A
.byte 0xF0
.byte 0x1E
.byte 0xDB
.byte 0xC6
.byte 0x7B
.byte 0x08
.byte 0x7D
.byte 0x01
.byte 0x7A
.byte 0x01
.byte 0x3A
.byte 0x07
.byte 0x13
.byte 0x97
.byte 0x00
.byte 0xEE
data_3C1:
.byte 0x3C
.byte 0x7E
.byte 0xFF
.byte 0xFF
.byte 0x99
.byte 0x99
.byte 0x7E
.byte 0xFF
.byte 0xFF
.byte 0x24
.byte 0x24
.byte 0xE7
.byte 0x7E
.byte 0xFF
.byte 0x3C
.byte 0x3C
.byte 0x7E
.byte 0xDB
.byte 0x81
.byte 0x42
.byte 0x3C
.byte 0x7E
.byte 0xFF
.byte 0xDB
data_3D9:
.byte 0x10
.byte 0x38
.byte 0x7C
.byte 0xFE
data_3DD:
.byte 0x00
.byte 0x00
.byte 0x7F
.byte 0x00
.byte 0x3F
.byte 0x00
.byte 0x7F
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x01
.byte 0x01
.byte 0x01
.byte 0x03
.byte 0x03
.byte 0x03
.byte 0x03
.byte 0x00
.byte 0x00
.byte 0x3F
.byte 0x20
.byte 0x20
.byte 0x20
.byte 0x20
.byte 0x20
.byte 0x20
.byte 0x20
.byte 0x20
.byte 0x3F
.byte 0x08
.byte 0x08
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFE
.byte 0x00
.byte 0xFC
.byte 0x00
.byte 0xFE
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x7E
.byte 0x42
.byte 0x42
.byte 0x62
.byte 0x62
.byte 0x62
.byte 0x62
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x7D
.byte 0x00
.byte 0x41
.byte 0x7D
.byte 0x05
.byte 0x7D
.byte 0x7D
.byte 0x00
.byte 0x00
.byte 0xC2
.byte 0xC2
.byte 0xC6
.byte 0x44
.byte 0x6C
.byte 0x28
.byte 0x38
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0xF7
.byte 0x10
.byte 0x14
.byte 0xF7
.byte 0xF7
.byte 0x04
.byte 0x04
.byte 0x00
.byte 0x00
.byte 0x7C
.byte 0x44
.byte 0xFE
.byte 0xC2
.byte 0xC2
.byte 0xC2
.byte 0xC2
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0xEF
.byte 0x20
.byte 0x28
.byte 0xE8
.byte 0xE8
.byte 0x2F
.byte 0x2F
.byte 0x00
.byte 0x00
.byte 0xF9
.byte 0x85
.byte 0xC5
.byte 0xC5
.byte 0xC5
.byte 0xC5
.byte 0xF9
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0xBE
.byte 0x00
.byte 0x20
.byte 0x30
.byte 0x20
.byte 0xBE
.byte 0xBE
.byte 0x00
.byte 0x00
.byte 0xF7
.byte 0x04
.byte 0xE7
.byte 0x85
.byte 0x85
.byte 0x84
.byte 0xF4
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x7F
.byte 0x00
.byte 0x3F
.byte 0x00
.byte 0x7F
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xEF
.byte 0x28
.byte 0xEF
.byte 0x00
.byte 0xE0
.byte 0x60
.byte 0x6F
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFF
.byte 0x00
.byte 0x00
.byte 0xFE
.byte 0x00
.byte 0xFC
.byte 0x00
.byte 0xFE
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0xC0
.byte 0x00
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0x00
.byte 0x00
.byte 0xFC
.byte 0x04
.byte 0x04
.byte 0x04
.byte 0x04
.byte 0x04
.byte 0x04
.byte 0x04
.byte 0x04
.byte 0xFC
.byte 0x10
.byte 0x10
.byte 0xFF
data_4DD:
.byte 0xF9
.byte 0x81
.byte 0xB9
.byte 0x8B
.byte 0x9A
.byte 0x9A
.byte 0xFA
.byte 0x00
.byte 0xFA
.byte 0x8A
.byte 0x9A
.byte 0x9A
.byte 0x9B
.byte 0x99
.byte 0xF8
.byte 0xE6
.byte 0x25
.byte 0x25
.byte 0xF4
.byte 0x34
.byte 0x34
.byte 0x34
.byte 0x00
.byte 0x17
.byte 0x14
.byte 0x34
.byte 0x37
.byte 0x36
.byte 0x26
.byte 0xC7
.byte 0xDF
.byte 0x50
.byte 0x50
.byte 0x5C
.byte 0xD8
.byte 0xD8
.byte 0xDF
.byte 0x00
.byte 0xDF
.byte 0x11
.byte 0x1F
.byte 0x12
.byte 0x1B
.byte 0x19
.byte 0xD9
.byte 0x7C
.byte 0x44
.byte 0xFE
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0xFC
.byte 0x84
.byte 0xFE
.byte 0x82
.byte 0x82
.byte 0xFE
.byte 0xFE
.byte 0x80
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0xFE
.byte 0xFC
.byte 0x82
.byte 0xC2
.byte 0xC2
.byte 0xC2
.byte 0xFC
.byte 0xFE
.byte 0x80
.byte 0xF8
.byte 0xC0
.byte 0xC0
.byte 0xFE
.byte 0xFE
.byte 0x80
.byte 0xF0
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0xFE
.byte 0x80
.byte 0xBE
.byte 0x86
.byte 0x86
.byte 0xFE
.byte 0x86
.byte 0x86
.byte 0xFE
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0x10
.byte 0x10
.byte 0x10
.byte 0x10
.byte 0x10
.byte 0x10
.byte 0x18
.byte 0x18
.byte 0x18
.byte 0x48
.byte 0x48
.byte 0x78
.byte 0x9C
.byte 0x90
.byte 0xB0
.byte 0xC0
.byte 0xB0
.byte 0x9C
.byte 0x80
.byte 0x80
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0xFE
.byte 0xEE
.byte 0x92
.byte 0x92
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0xFE
.byte 0x82
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0x7C
.byte 0x82
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0x7C
.byte 0xFE
.byte 0x82
.byte 0xFE
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0x7C
.byte 0x82
.byte 0xC2
.byte 0xCA
.byte 0xC4
.byte 0x7A
.byte 0xFE
.byte 0x86
.byte 0xFE
.byte 0x90
.byte 0x9C
.byte 0x84
.byte 0xFE
.byte 0xC0
.byte 0xFE
.byte 0x02
.byte 0x02
.byte 0xFE
.byte 0xFE
.byte 0x10
.byte 0x30
.byte 0x30
.byte 0x30
.byte 0x30
.byte 0x82
.byte 0x82
.byte 0xC2
.byte 0xC2
.byte 0xC2
.byte 0xFE
.byte 0x82
.byte 0x82
.byte 0x82
.byte 0xEE
.byte 0x38
.byte 0x10
.byte 0x86
.byte 0x86
.byte 0x96
.byte 0x92
.byte 0x92
.byte 0xEE
.byte 0x82
.byte 0x44
.byte 0x38
.byte 0x38
.byte 0x44
.byte 0x82
.byte 0x82
.byte 0x82
.byte 0xFE
.byte 0x30
.byte 0x30
.byte 0x30
.byte 0xFE
.byte 0x02
.byte 0x1E
.byte 0xF0
.byte 0x80
.byte 0xFE
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x06
.byte 0x06
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x60
.byte 0x60
.byte 0xC0
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x18
.byte 0x18
.byte 0x18
.byte 0x18
.byte 0x00
.byte 0x18
.byte 0x7C
.byte 0xC6
.byte 0x0C
.byte 0x18
.byte 0x00
.byte 0x18
.byte 0x00
.byte 0x00
.byte 0xFE
.byte 0xFE
.byte 0x00
.byte 0x00
.byte 0xFE
.byte 0x82
.byte 0x86
.byte 0x86
.byte 0x86
.byte 0xFE
.byte 0x08
.byte 0x08
.byte 0x08
.byte 0x18
.byte 0x18
.byte 0x18
.byte 0xFE
.byte 0x02
.byte 0xFE
.byte 0xC0
.byte 0xC0
.byte 0xFE
.byte 0xFE
.byte 0x02
.byte 0x1E
.byte 0x06
.byte 0x06
.byte 0xFE
.byte 0x84
.byte 0xC4
.byte 0xC4
.byte 0xFE
.byte 0x04
.byte 0x04
.byte 0xFE
.byte 0x80
.byte 0xFE
.byte 0x06
.byte 0x06
.byte 0xFE
.byte 0xC0
.byte 0xC0
.byte 0xC0
.byte 0xFE
.byte 0x82
.byte 0xFE
.byte 0xFE
.byte 0x02
.byte 0x02
.byte 0x06
.byte 0x06
.byte 0x06
.byte 0x7C
.byte 0x44
.byte 0xFE
.byte 0x86
.byte 0x86
.byte 0xFE
.byte 0xFE
.byte 0x82
.byte 0xFE
.byte 0x06
.byte 0x06
.byte 0x06
.byte 0x44
.byte 0xFE
.byte 0x44
.byte 0x44
.byte 0xFE
.byte 0x44
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0x6C
.byte 0x5A
.byte 0x00
.byte 0x0C
.byte 0x18
.byte 0xA8
.byte 0x30
.byte 0x4E
.byte 0x7E
.byte 0x00
.byte 0x12
.byte 0x18
.byte 0x66
.byte 0x6C
.byte 0xA8
.byte 0x5A
.byte 0x66
.byte 0x54
.byte 0x24
.byte 0x66
.byte 0x00
.byte 0x48
.byte 0x48
.byte 0x18
.byte 0x12
.byte 0xA8
.byte 0x06
.byte 0x90
.byte 0xA8
.byte 0x12
.byte 0x00
.byte 0x7E
.byte 0x30
.byte 0x12
.byte 0xA8
.byte 0x84
.byte 0x30
.byte 0x4E
.byte 0x72
.byte 0x18
.byte 0x66
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0x90
.byte 0x54
.byte 0x78
.byte 0xA8
.byte 0x48
.byte 0x78
.byte 0x6C
.byte 0x72
.byte 0xA8
.byte 0x12
.byte 0x18
.byte 0x6C
.byte 0x72
.byte 0x66
.byte 0x54
.byte 0x90
.byte 0xA8
.byte 0x72
.byte 0x2A
.byte 0x18
.byte 0xA8
.byte 0x30
.byte 0x4E
.byte 0x7E
.byte 0x00
.byte 0x12
.byte 0x18
.byte 0x66
.byte 0x6C
.byte 0xA8
.byte 0x72
.byte 0x54
.byte 0xA8
.byte 0x5A
.byte 0x66
.byte 0x18
.byte 0x7E
.byte 0x18
.byte 0x4E
.byte 0x72
.byte 0xA8
.byte 0x72
.byte 0x2A
.byte 0x18
.byte 0x30
.byte 0x66
.byte 0xA8
.byte 0x30
.byte 0x4E
.byte 0x7E
.byte 0x00
.byte 0x6C
.byte 0x30
.byte 0x54
.byte 0x4E
.byte 0x9C
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0x48
.byte 0x54
.byte 0x7E
.byte 0x18
.byte 0xA8
.byte 0x90
.byte 0x54
.byte 0x78
.byte 0x66
.byte 0xA8
.byte 0x6C
.byte 0x2A
.byte 0x30
.byte 0x5A
.byte 0xA8
.byte 0x84
.byte 0x30
.byte 0x72
.byte 0x2A
.byte 0xA8
.byte 0xD8
.byte 0xA8
.byte 0x00
.byte 0x4E
.byte 0x12
.byte 0xA8
.byte 0xE4
.byte 0xA2
.byte 0xA8
.byte 0x00
.byte 0x4E
.byte 0x12
.byte 0xA8
.byte 0x6C
.byte 0x2A
.byte 0x54
.byte 0x54
.byte 0x72
.byte 0xA8
.byte 0x84
.byte 0x30
.byte 0x72
.byte 0x2A
.byte 0xA8
.byte 0xDE
.byte 0x9C
.byte 0xA8
.byte 0x72
.byte 0x2A
.byte 0x18
.byte 0xA8
.byte 0x0C
.byte 0x54
.byte 0x48
.byte 0x5A
.byte 0x78
.byte 0x72
.byte 0x18
.byte 0x66
.byte 0xA8
.byte 0x66
.byte 0x18
.byte 0x5A
.byte 0x54
.byte 0x66
.byte 0x72
.byte 0x6C
.byte 0xA8
.byte 0x72
.byte 0x2A
.byte 0x00
.byte 0x72
.byte 0xA8
.byte 0x72
.byte 0x2A
.byte 0x18
.byte 0xA8
.byte 0x30
.byte 0x4E
.byte 0x7E
.byte 0x00
.byte 0x12
.byte 0x18
.byte 0x66
.byte 0x6C
.byte 0xA8
.byte 0x00
.byte 0x66
.byte 0x18
.byte 0xA8
.byte 0x30
.byte 0x4E
.byte 0x0C
.byte 0x66
.byte 0x18
.byte 0x00
.byte 0x6C
.byte 0x30
.byte 0x4E
.byte 0x24
.byte 0xA8
.byte 0x72
.byte 0x2A
.byte 0x18
.byte 0x30
.byte 0x66
.byte 0xA8
.byte 0x1E
.byte 0x54
.byte 0x66
.byte 0x0C
.byte 0x18
.byte 0x9C
.byte 0xA8
.byte 0x24
.byte 0x54
.byte 0x54
.byte 0x12
.byte 0xA8
.byte 0x42
.byte 0x78
.byte 0x0C
.byte 0x3C
.byte 0xA8
.byte 0xAE
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xA8
.byte 0xFF
data_706:
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
.byte 0x00
Hi, all.
I'm making a Chip 8 Emulator in Javascript, and progress is going great, but I ran into a problem that renders games unplayable.
Opcode 0.
This Opcode 0x0000 seems to not have any function mapped to it.
Maybe it's for idling, but I don't know how to make the emulator idle properly if that's the case.
I have no idea what it is, or what to do with it, but it seems to freeze games solid.
Here's the link to my Github of the emulator.
https://github.com/CyanPrime/Chip-8-Emu-JS
Can anyone help me understand what to do here? Any help would be very appreciated.
Your handling an opcode incorrectly, resulting in that incorrect address.
--
I took a quick glance through your source...
This:
//8XYE
//Shifts VX left by one. VF is set to the value of the most significant bit of VX before the shift.
case 0x000E:
this.V[0xF] = this.V[(this.opcode & 0x0F00) >> 8] & 0x7;
this.V[(this.opcode & 0x0F00) >> 8] >>= 1;
this.pc += 2;
break;
Should be:
//8XYE
//Shifts VX left by one. VF is set to the value of the most significant bit of VX before the shift.
case 0x000E:
this.V[0xF] = ( this.V[(this.opcode & 0x0F00) >> 8] & 0x80) >> 7; // CHANGED
this.V[(this.opcode & 0x0F00) >> 8] <<= 1; // CHANGED
this.pc += 2;
break;
--
I'll take another look tomorrow (3am here) but that is one fix at least
var memory = new ArrayBuffer(0x1000);
this.memory = new Uint8Array(memory);
// Reset memory.
for (i = 0; i < this.memory.length; i++) {
this.memory = 0;
}
this.chip8_fontset =
[
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
0xF0, 0x10, 0x20, 0x40, 0x40, // 7
0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
0xF0, 0x90, 0xF0, 0x90, 0x90, // A
0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
0xF0, 0x80, 0x80, 0x80, 0xF0, // C
0xE0, 0x90, 0x90, 0x90, 0xE0, // D
0xF0, 0x80, 0xF0, 0x80, 0xF0, // E
0xF0, 0x80, 0xF0, 0x80, 0x80 // F
];
for (i = 0; i < this.chip8_fontset.length; i++) {
this.memory = this.chip8_fontset;
}
this.V = new Array(16);
Your handling an opcode incorrectly, resulting in that incorrect address.
--
I took a quick glance through your source...
This:
//8XYE
//Shifts VX left by one. VF is set to the value of the most significant bit of VX before the shift.
case 0x000E:
this.V[0xF] = this.V[(this.opcode & 0x0F00) >> 8] & 0x7;
this.V[(this.opcode & 0x0F00) >> 8] >>= 1;
this.pc += 2;
break;
Should be:
//8XYE
//Shifts VX left by one. VF is set to the value of the most significant bit of VX before the shift.
case 0x000E:
this.V[0xF] = ( this.V[(this.opcode & 0x0F00) >> 8] & 0x80) >> 7; // CHANGED
this.V[(this.opcode & 0x0F00) >> 8] <<= 1; // CHANGED
this.pc += 2;
break;
--
I'll take another look tomorrow (3am here) but that is one fix at least
var memory = new ArrayBuffer(0x1000);
this.memory = new Uint8Array(memory);
// Reset memory.
for (i = 0; i < this.memory.length; i++) {
this.memory = 0;
}
this.chip8_fontset =
[
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0x10, 0x10, // 4
0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
0xF0, 0x10, 0x20, 0x40, 0x40, // 7
0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
0xF0, 0x90, 0xF0, 0x90, 0x90, // A
0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
0xF0, 0x80, 0x80, 0x80, 0xF0, // C
0xE0, 0x90, 0x90, 0x90, 0xE0, // D
0xF0, 0x80, 0xF0, 0x80, 0xF0, // E
0xF0, 0x80, 0xF0, 0x80, 0x80 // F
];
for (i = 0; i < this.chip8_fontset.length; i++) {
this.memory = this.chip8_fontset;
}
this.V = new Array(16);
Thank you very much for seeing that. It didn't seem to have any effect on the current problem, but I'm sure it saved me a headache down the line, lol.
I found out my error was from not having my font loaded into memory.
However, now I get a unknown opcode of F090 after the screen clearing opcode.
I've updated Github with current source (throwing the F090 error). ...or not, because Github keeps crashing on me now :<
Here's the change:
Sorry about not being able to make this easier via github...
- - - Updated - - -
Thank you very much for seeing that. It didn't seem to have any effect on the current problem, but I'm sure it saved me a headache down the line, lol.
I found out my error was from not having my font loaded into memory.
However, now I get a unknown opcode of F090 after the screen clearing opcode.
I've updated Github with current source (throwing the F090 error). ...or not, because Github keeps crashing on me now :<
Here's the change:
Sorry about not being able to make this easier via github...
I FIGURED IT OUT!
I was missing a break in my switch statement. >_>
Now my only problem is that my button input seems to be not working.
If anyone can help me with that that'd be great.
Awesome!
Do you happen to have the flipped graphics issue I described above?
If not, maybe you can see where i'm going wrong? I'm stumped :S
You can see how i handle control input also, to help you.
Relevant code: https://gist.github.com/DannyGlover/331078ceedfee12732f8
// Draw
- (void)draw: (id)sender {
for(int x = 0; x < 64; x++){
for(int y = 0; y < 32; y++){
// Set the pixel's color
int i = (y * 64) + x;
screen.layer.backgroundColor = ( graphics == 0 ) ? [NSColor blackColor].CGColor : [NSColor whiteColor].CGColor;
}
}
// Turn off the draw flag
drawFlag = false;
}
"this.sp;2: 1" main.js:197
"this.pc1: 544" main.js:198
"this.pc2: 758" main.js:200
"set I to: 788" main.js:372
"call opcode: 6XNN" main.js:227
"full opcode: 6337" main.js:228
"this.V[x] =0" main.js:229
"(this.opcode & 0x00FF) =55" main.js:230
"(this.opcode & 0x00FF) 16 =37" main.js:231
"call opcode: 6XNN" main.js:227
"full opcode: 6400" main.js:228
"this.V[x] =0" main.js:229
"(this.opcode & 0x00FF) =0" main.js:230
"(this.opcode & 0x00FF) 16 =0" main.js:231
"call opcode 0xDXYN" main.js:386
"full opcode: d345" main.js:387
"call opcode 0xDXYN" main.js:386
"full opcode: d345" main.js:387
"Returns from subroutine" main.js:159
"this.sp;1: 1" main.js:160
"this.sp;2: 0" main.js:162
"this.pc: 778" main.js:163
"this.stack[this.sp]: 544" main.js:164
"this.pc: 544" main.js:166
"call opcode: 6XNN" main.js:227
"full opcode: 6000" main.js:228
"this.V[x] =0" main.js:229
"(this.opcode & 0x00FF) =0" main.js:230
"(this.opcode & 0x00FF) 16 =0" main.js:231
"call opcode: 6XNN" main.js:227
"full opcode: 6100" main.js:228
"this.V[x] =0" main.js:229
"(this.opcode & 0x00FF) =0" main.js:230
"(this.opcode & 0x00FF) 16 =0" main.js:231
"set I to: 786" main.js:372
"call opcode 0xDXYN" main.js:386
"full opcode: d011" main.js:387
"set I to: 782" main.js:372
"call opcode 0xDXYN" main.js:386
"full opcode: d011" main.js:387
"call opcode: 6XNN" main.js:227
"full opcode: 6040" main.js:228
"this.V[x] =8" main.js:229
"(this.opcode & 0x00FF) =64" main.js:230
"(this.opcode & 0x00FF) 16 =40" main.js:231
"jump to addr: 564"
[MENTION=29773]_Zack_[/MENTION] Could it be that the Chip 8 orders pixels from left to right and top to bottom while the library you use to output does it from left to right and bottom to top? Anyway, that is not standard, so there's is probably an error in the code outputting the array screen, not in the gist you linked.
[MENTION=94827]CyanPrime[/MENTION] Do you happen to have my space invaders bug?Hi, I got my emulator working really well. The only bug I can see is that moving objects in games flicker the whole time. If anyone has had this bug, and fixed it could you let me know how?
There's a github link with my current code at the top of this page.
1NNN Jump to NNN
6XKK VX = KK
6XKK VX = KK
6XKK VX = KK
ANNN I = NNN
DXYN Draws a sprite at (VX,VY) starting at M(I). VF = collision.
7XKK VX = VX + KK
FX1E I = I + VX
3XKK Skip next instruction if VX == KK
1NNN Jump to NNN
DXYN Draws a sprite at (VX,VY) starting at M(I). VF = collision.
7XKK VX = VX + KK
FX1E I = I + VX
3XKK Skip next instruction if VX == KK
1NNN Jump to NNN
DXYN Draws a sprite at (VX,VY) starting at M(I). VF = collision.
7XKK VX = VX + KK
FX1E I = I + VX
3XKK Skip next instruction if VX == KK
1NNN Jump to NNN
DXYN Draws a sprite at (VX,VY) starting at M(I). VF = collision.
7XKK VX = VX + KK
FX1E I = I + VX
And so on...