Annotation of hatari/src/stMemory.c, revision 1.1.1.2

1.1       root        1: /*
                      2:   Hatari
                      3: 
                      4:   ST Memory functions - takes care of endian swaps
                      5: */
                      6: 
1.1.1.2 ! root        7: #include <SDL_endian.h>
        !             8: 
1.1       root        9: #include "main.h"
                     10: #include "decode.h"
                     11: #include "m68000.h"
                     12: #include "memAlloc.h"
                     13: 
1.1.1.2 ! root       14: 
        !            15: /*-----------------------------------------------------------------------*/
1.1       root       16: /*
                     17:   Clear section of ST's memory space
                     18: */
                     19: void STMemory_Clear(unsigned long StartAddress, unsigned long EndAddress)
                     20: {
                     21:   Memory_Clear((void *)((unsigned long)STRam+StartAddress),EndAddress-StartAddress);
                     22: }
                     23: 
1.1.1.2 ! root       24: 
        !            25: /*-----------------------------------------------------------------------*/
1.1       root       26: /*
                     27:   Swap 16-bit integer to/from 68000/PC format
                     28: */
                     29: unsigned short int STMemory_Swap68000Int(unsigned short int var)
                     30: {
1.1.1.2 ! root       31:  return SDL_SwapBE16(var);
1.1       root       32: }
                     33: 
1.1.1.2 ! root       34: /*-----------------------------------------------------------------------*/
1.1       root       35: /*
                     36:   Swap 32-bit integer to/from 68000/PC format
                     37: */
                     38: unsigned long STMemory_Swap68000Long(unsigned long var)
                     39: {
1.1.1.2 ! root       40:  return SDL_SwapBE32(var);
1.1       root       41: }
                     42: 
1.1.1.2 ! root       43: 
        !            44: /*-----------------------------------------------------------------------*/
1.1       root       45: /*
                     46:   Write 32-bit word into ST memory space, NOTE - value will be convert to 68000 endian
                     47: */
                     48: void STMemory_WriteLong(unsigned long Address,unsigned long Var)
                     49: {
                     50:   unsigned long *pLongWord;
                     51: 
                     52:   Address &= 0xffffff;
                     53:   pLongWord = (unsigned long *)((unsigned long)STRam+Address);
                     54:   *pLongWord = STMemory_Swap68000Long(Var);
                     55: }
                     56: 
1.1.1.2 ! root       57: /*-----------------------------------------------------------------------*/
1.1       root       58: /*
                     59:   Write 16-bit word into ST memory space, NOTE - value will be convert to 68000 endian
                     60: */
                     61: void STMemory_WriteWord(unsigned long Address,unsigned short int Var)
                     62: {
                     63:   unsigned short int *pShortWord;
                     64: 
                     65:   Address &= 0xffffff;
                     66:   pShortWord = (unsigned short int *)((unsigned long)STRam+Address);
                     67:   *pShortWord = STMemory_Swap68000Int(Var);
                     68: }
                     69: 
1.1.1.2 ! root       70: /*-----------------------------------------------------------------------*/
1.1       root       71: /*
                     72:   Write 8-bit byte into ST memory space
                     73: */
                     74: void STMemory_WriteByte(unsigned long Address,unsigned char Var)
                     75: {
                     76:   unsigned char *pChar;
                     77: 
                     78:   Address &= 0xffffff;
                     79:   pChar = (unsigned char *)((unsigned long)STRam+Address);
                     80:   *pChar = Var;
                     81: }
                     82: 
1.1.1.2 ! root       83: 
        !            84: /*-----------------------------------------------------------------------*/
1.1       root       85: /*
                     86:   Read 32-bit word from ST memory space, NOTE - value will be converted to PC endian
                     87: */
                     88: unsigned long STMemory_ReadLong(unsigned long Address)
                     89: {
                     90:   unsigned long *pLongWord;
                     91: 
                     92:   Address &= 0xffffff;
                     93:   pLongWord = (unsigned long *)((unsigned long)STRam+Address);
                     94:   return( STMemory_Swap68000Long(*pLongWord) );
                     95: }
                     96: 
1.1.1.2 ! root       97: /*-----------------------------------------------------------------------*/
1.1       root       98: /*
                     99:   Read 16-bit word from ST memory space, NOTE - value will be converted to PC endian
                    100: */
                    101: unsigned short int STMemory_ReadWord(unsigned long Address)
                    102: {
                    103:   unsigned short int *pShortWord;
                    104: 
                    105:   Address &= 0xffffff;
                    106:   pShortWord = (unsigned short int *)((unsigned long)STRam+Address);
                    107:   return( STMemory_Swap68000Int(*pShortWord) );
                    108: }
                    109: 
1.1.1.2 ! root      110: /*-----------------------------------------------------------------------*/
1.1       root      111: /*
                    112:   Read 8-bit byte from ST memory space
                    113: */
                    114: unsigned char STMemory_ReadByte(unsigned long Address)
                    115: {
                    116:   unsigned char *pChar;
                    117: 
                    118:   Address &= 0xffffff;
                    119:   pChar = (unsigned char *)((unsigned long)STRam+Address);
                    120:   return( *pChar );
                    121: }
                    122: 
1.1.1.2 ! root      123: 
        !           124: /*-----------------------------------------------------------------------*/
1.1       root      125: /*
                    126:   Write 32-bit word into PC memory space, NOTE - value will be convert to 68000 endian
                    127: */
                    128: void STMemory_WriteLong_PCSpace(void *pAddress,unsigned long Var)
                    129: {
                    130:   unsigned long *pLongWord=(unsigned long *)pAddress;
                    131: 
                    132:   *pLongWord = STMemory_Swap68000Long(Var);
                    133: }
                    134: 
1.1.1.2 ! root      135: /*-----------------------------------------------------------------------*/
1.1       root      136: /*
                    137:   Write 16-bit word into PC memory space, NOTE - value will be convert to 68000 endian
                    138: */
                    139: void STMemory_WriteWord_PCSpace(void *pAddress,unsigned short int Var)
                    140: {
                    141:   unsigned short int *pShortWord=(unsigned short int *)pAddress;
                    142: 
                    143:   *pShortWord = STMemory_Swap68000Int(Var);
                    144: }
                    145: 
1.1.1.2 ! root      146: 
        !           147: /*-----------------------------------------------------------------------*/
1.1       root      148: /*
                    149:   Read 32-bit word from PC memory space, NOTE - value will be convert to 68000 endian
                    150: */
                    151: unsigned long STMemory_ReadLong_PCSpace(void *pAddress)
                    152: {
                    153:   unsigned long *pLongWord=(unsigned long *)pAddress;
                    154: 
                    155:   return( STMemory_Swap68000Long(*pLongWord) );
                    156: }
                    157: 
1.1.1.2 ! root      158: /*-----------------------------------------------------------------------*/
1.1       root      159: /*
                    160:   Read 16-bit word from PC memory space, NOTE - value will be convert to 68000 endian
                    161: */
                    162: unsigned short int STMemory_ReadWord_PCSpace(void *pAddress)
                    163: {
                    164:   unsigned short int *pShortWord=(unsigned short int *)pAddress;
                    165: 
                    166:   return( STMemory_Swap68000Int(*pShortWord) );
                    167: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.