finished first row of opcodes

This commit is contained in:
radumacocian
2025-06-30 15:58:53 +02:00
parent eddfb7a0c6
commit 0f4a97bbf2
6 changed files with 105 additions and 31 deletions

View File

@@ -1,6 +1,10 @@
package cpu
func Set8BitAddFlags(context op_context, byte1 byte, byte2 byte) byte {
import (
"radu.macocian.me/goboy/cpu/operations"
)
func Add8BitsAndSetFlags(context op_context, byte1 byte, byte2 byte) byte {
result := uint16(byte1) + uint16(byte2)
halfcarry := (byte1&0x0F)+(byte2&0x0F) > 0x0F
context.cpu.SetNF(false)
@@ -17,3 +21,19 @@ func Add16BitsAndSetFlags(context op_context, op1 uint16, op2 uint16) uint16 {
context.cpu.SetCF(result > 0xFFFF)
return uint16(result)
}
func IncAndSetFlags(context op_context, op1 *byte) {
halfcarry := *op1&0x0F == 0x0F
context.cpu.SetNF(false)
context.cpu.SetHF(halfcarry)
context.cpu.SetZF(*op1 == byte(0))
operations.INC(op1)
}
func DecAndSetFlags(context op_context, op1 *byte) {
halfcarry := *op1&0x0F == 0x00
context.cpu.SetZF(*op1 == byte(0))
context.cpu.SetNF(true)
context.cpu.SetHF(halfcarry)
operations.DEC(op1)
}