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

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

unix.superglobalmegacorp.com

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