comparison src/gb/GB.cpp @ 100:2090bcb78f44

created functions to get and set register values
author Robert McIntyre <rlm@mit.edu>
date Mon, 12 Mar 2012 12:37:04 -0500
parents cb487c4ce5c0
children 893c753f8088
comparison
equal deleted inserted replaced
99:9fad96094950 100:2090bcb78f44
3932 for (i = 0; i < 0x4000; i++){ 3932 for (i = 0; i < 0x4000; i++){
3933 store[i] = (int32) gbVram[i]; 3933 store[i] = (int32) gbVram[i];
3934 } 3934 }
3935 } 3935 }
3936 3936
3937
3937 void storeRegisters(int32* store){ 3938 void storeRegisters(int32* store){
3938 store[0] = (int32) PC.W; 3939 store[0] = (int32) PC.W;
3939 store[1] = (int32) SP.W; 3940 store[1] = (int32) SP.W;
3940 store[2] = (int32) AF.W; 3941 store[2] = (int32) AF.W;
3941 store[3] = (int32) BC.W; 3942 store[3] = (int32) BC.W;
3942 store[4] = (int32) DE.W; 3943 store[4] = (int32) DE.W;
3943 store[5] = (int32) HL.W; 3944 store[5] = (int32) HL.W;
3944 store[6] = (int32) register_DIV; 3945
3945 store[7] = (int32) register_TIMA; 3946 store[6] = (int32) IFF;
3946 store[8] = (int32) register_TMA; 3947
3947 store[9] = (int32) register_TAC; 3948 store[7] = (int32) register_DIV;
3948 store[10] = (int32) register_IF; 3949 store[8] = (int32) register_TIMA;
3949 store[11] = (int32) register_LCDC; 3950 store[9] = (int32) register_TMA;
3950 store[12] = (int32) register_STAT; 3951 store[10] = (int32) register_TAC;
3951 store[13] = (int32) register_SCY; 3952 store[11] = (int32) register_IF;
3952 store[14] = (int32) register_SCX; 3953 store[12] = (int32) register_LCDC;
3953 store[15] = (int32) register_LY; 3954 store[13] = (int32) register_STAT;
3954 store[16] = (int32) register_LYC; 3955 store[14] = (int32) register_SCY;
3955 store[17] = (int32) register_DMA; 3956 store[15] = (int32) register_SCX;
3956 store[18] = (int32) register_WY; 3957 store[16] = (int32) register_LY;
3957 store[19] = (int32) register_WX; 3958 store[17] = (int32) register_LYC;
3958 store[20] = (int32) register_VBK; 3959 store[18] = (int32) register_DMA;
3959 store[21] = (int32) register_HDMA1; 3960 store[19] = (int32) register_WY;
3960 store[22] = (int32) register_HDMA2; 3961 store[20] = (int32) register_WX;
3961 store[23] = (int32) register_HDMA3; 3962 store[21] = (int32) register_VBK;
3962 store[24] = (int32) register_HDMA4; 3963 store[22] = (int32) register_HDMA1;
3963 store[25] = (int32) register_HDMA5; 3964 store[23] = (int32) register_HDMA2;
3964 store[26] = (int32) register_SVBK; 3965 store[24] = (int32) register_HDMA3;
3965 store[27] = (int32) register_IE; 3966 store[25] = (int32) register_HDMA4;
3967 store[26] = (int32) register_HDMA5;
3968 store[27] = (int32) register_SVBK;
3969 store[28] = (int32) register_IE;
3970 }
3971
3972 void setRegisters(int32* registers){
3973 PC.W = (u16) (0xFFFF & registers[0]);
3974 SP.W = (u16) (0xFFFF & registers[1]);
3975 AF.W = (u16) (0xFFFF & registers[2]);
3976 BC.W = (u16) (0xFFFF & registers[3]);
3977 DE.W = (u16) (0xFFFF & registers[4]);
3978 HL.W = (u16) (0xFFFF & registers[5]);
3979 IFF = (u16) (0xFFFF & registers[6]);
3980
3981 register_DIV = (u8) (0xFF & registers[7]);
3982 register_TIMA = (u8) (0xFF & registers[8]);
3983 register_TMA = (u8) (0xFF & registers[9]);
3984 register_TAC = (u8) (0xFF & registers[10]);
3985 register_IF = (u8) (0xFF & registers[11]);
3986 register_LCDC = (u8) (0xFF & registers[12]);
3987 register_STAT = (u8) (0xFF & registers[13]);
3988 register_SCY = (u8) (0xFF & registers[14]);
3989 register_SCX = (u8) (0xFF & registers[15]);
3990 register_LY = (u8) (0xFF & registers[16]);
3991 register_LYC = (u8) (0xFF & registers[17]);
3992 register_DMA = (u8) (0xFF & registers[18]);
3993 register_WY = (u8) (0xFF & registers[19]);
3994 register_WX = (u8) (0xFF & registers[20]);
3995 register_VBK = (u8) (0xFF & registers[21]);
3996 register_HDMA1 = (u8) (0xFF & registers[22]);
3997 register_HDMA2 = (u8) (0xFF & registers[23]);
3998 register_HDMA3 = (u8) (0xFF & registers[24]);
3999 register_HDMA4 = (u8) (0xFF & registers[25]);
4000 register_HDMA5 = (u8) (0xFF & registers[26]);
4001 register_SVBK = (u8) (0xFF & registers[27]);
4002 register_IE = (u8) (0xFF & registers[28]);
3966 } 4003 }
3967 4004
3968 struct EmulatedSystem GBSystem = 4005 struct EmulatedSystem GBSystem =
3969 { 4006 {
3970 // emuMain 4007 // emuMain