diff options
Diffstat (limited to 'apps/codecs/libasap/asap_internal.h')
-rw-r--r-- | apps/codecs/libasap/asap_internal.h | 91 |
1 files changed, 57 insertions, 34 deletions
diff --git a/apps/codecs/libasap/asap_internal.h b/apps/codecs/libasap/asap_internal.h index 1385215f37..1e38496344 100644 --- a/apps/codecs/libasap/asap_internal.h +++ b/apps/codecs/libasap/asap_internal.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * asap_internal.h - private interface of the ASAP engine | 2 | * asap_internal.h - private interface of ASAP |
3 | * | 3 | * |
4 | * Copyright (C) 2005-2008 Piotr Fusik | 4 | * Copyright (C) 2005-2010 Piotr Fusik |
5 | * | 5 | * |
6 | * This file is part of ASAP (Another Slight Atari Player), | 6 | * This file is part of ASAP (Another Slight Atari Player), |
7 | * see http://asap.sourceforge.net | 7 | * see http://asap.sourceforge.net |
@@ -24,33 +24,35 @@ | |||
24 | #ifndef _ASAP_INTERNAL_H_ | 24 | #ifndef _ASAP_INTERNAL_H_ |
25 | #define _ASAP_INTERNAL_H_ | 25 | #define _ASAP_INTERNAL_H_ |
26 | 26 | ||
27 | #if !defined(JAVA) && !defined(CSHARP) | 27 | #include "anylang.h" |
28 | 28 | ||
29 | #include "asap.h" | 29 | #ifndef C |
30 | |||
31 | #define ASAP_SONGS_MAX 32 | ||
32 | #define ASAP_SAMPLE_RATE 44100 | ||
33 | |||
34 | #endif | ||
35 | |||
36 | #ifdef JAVA | ||
37 | |||
38 | #define ASAP_FORMAT_U8 8 | ||
39 | #define ASAP_FORMAT_S16_LE 16 | ||
40 | #define ASAP_FORMAT_S16_BE -16 | ||
41 | #define ASAP_SampleFormat int | ||
42 | |||
43 | #elif defined(CSHARP) || defined(JAVASCRIPT) | ||
44 | |||
45 | #define ASAP_FORMAT_U8 ASAP_SampleFormat.U8 | ||
46 | #define ASAP_FORMAT_S16_LE ASAP_SampleFormat.S16LE | ||
47 | #define ASAP_FORMAT_S16_BE ASAP_SampleFormat.S16BE | ||
30 | 48 | ||
31 | #define CONST_LOOKUP(type, name) \ | 49 | #elif defined(ACTIONSCRIPT) |
32 | static const type name[] | 50 | |
33 | #define FILE_FUNC static | 51 | #define ASAP_SampleFormat int |
34 | #define ASAP_FUNC | 52 | |
35 | #define PTR * | 53 | #else /* C */ |
36 | #define ADDRESSOF & | 54 | |
37 | #define ARRAY * | 55 | #include "asap.h" |
38 | #define VOIDPTR void * | ||
39 | #define UBYTE(data) (data) | ||
40 | #define SBYTE(data) (signed char) (data) | ||
41 | #define STRING const char * | ||
42 | #define ZERO_ARRAY(array) memset(array, 0, sizeof(array)) | ||
43 | #define COPY_ARRAY(dest, dest_offset, src, src_offset, len) \ | ||
44 | memcpy(dest + dest_offset, src + src_offset, len) | ||
45 | #define NEW_ARRAY(type, name, size) \ | ||
46 | type name[size] | ||
47 | #define INIT_ARRAY(array) memset(array, 0, sizeof(array)) | ||
48 | |||
49 | #define AST ast-> | ||
50 | #define PST pst-> | ||
51 | #define MODULE_INFO module_info-> | ||
52 | #define ASAP_OBX const byte * | ||
53 | #define GET_OBX(name) name##_obx | ||
54 | 56 | ||
55 | int ASAP_GetByte(ASAP_State *ast, int addr); | 57 | int ASAP_GetByte(ASAP_State *ast, int addr); |
56 | void ASAP_PutByte(ASAP_State *ast, int addr, int data); | 58 | void ASAP_PutByte(ASAP_State *ast, int addr, int data); |
@@ -60,7 +62,7 @@ void Cpu_RunScanlines(ASAP_State *ast, int scanlines); | |||
60 | void PokeySound_Initialize(ASAP_State *ast); | 62 | void PokeySound_Initialize(ASAP_State *ast); |
61 | void PokeySound_StartFrame(ASAP_State *ast); | 63 | void PokeySound_StartFrame(ASAP_State *ast); |
62 | void PokeySound_PutByte(ASAP_State *ast, int addr, int data); | 64 | void PokeySound_PutByte(ASAP_State *ast, int addr, int data); |
63 | int PokeySound_GetRandom(ASAP_State *ast, int addr); | 65 | int PokeySound_GetRandom(ASAP_State *ast, int addr, int cycle); |
64 | void PokeySound_EndFrame(ASAP_State *ast, int cycle_limit); | 66 | void PokeySound_EndFrame(ASAP_State *ast, int cycle_limit); |
65 | int PokeySound_Generate(ASAP_State *ast, byte buffer[], int buffer_offset, int blocks, ASAP_SampleFormat format); | 67 | int PokeySound_Generate(ASAP_State *ast, byte buffer[], int buffer_offset, int blocks, ASAP_SampleFormat format); |
66 | abool PokeySound_IsSilent(const PokeyState *pst); | 68 | abool PokeySound_IsSilent(const PokeyState *pst); |
@@ -68,11 +70,11 @@ void PokeySound_Mute(const ASAP_State *ast, PokeyState *pst, int mask); | |||
68 | 70 | ||
69 | #ifdef ASAPSCAN | 71 | #ifdef ASAPSCAN |
70 | abool call_6502_player(ASAP_State *ast); | 72 | abool call_6502_player(ASAP_State *ast); |
71 | extern abool cpu_trace; | 73 | extern int cpu_trace; |
72 | void print_cpu_state(const ASAP_State *ast, int pc, int a, int x, int y, int s, int nz, int vdi, int c); | 74 | void trace_cpu(const ASAP_State *ast, int pc, int a, int x, int y, int s, int nz, int vdi, int c); |
73 | #endif | 75 | #endif |
74 | 76 | ||
75 | #endif /* !defined(JAVA) && !defined(CSHARP) */ | 77 | #endif /* C */ |
76 | 78 | ||
77 | #define ASAP_MAIN_CLOCK 1773447 | 79 | #define ASAP_MAIN_CLOCK 1773447 |
78 | 80 | ||
@@ -83,11 +85,32 @@ void print_cpu_state(const ASAP_State *ast, int pc, int a, int x, int y, int s, | |||
83 | 85 | ||
84 | #define NEVER 0x800000 | 86 | #define NEVER 0x800000 |
85 | 87 | ||
86 | #define dGetByte(addr) UBYTE(AST memory[addr]) | 88 | #define DELTA_SHIFT_POKEY 20 |
87 | #define dPutByte(addr, data) AST memory[addr] = (byte) (data) | 89 | #define DELTA_SHIFT_GTIA 20 |
90 | #define DELTA_SHIFT_COVOX 17 | ||
91 | |||
92 | /* 6502 player types */ | ||
93 | #define ASAP_TYPE_SAP_B 1 | ||
94 | #define ASAP_TYPE_SAP_C 2 | ||
95 | #define ASAP_TYPE_SAP_D 3 | ||
96 | #define ASAP_TYPE_SAP_S 4 | ||
97 | #define ASAP_TYPE_CMC 5 | ||
98 | #define ASAP_TYPE_CM3 6 | ||
99 | #define ASAP_TYPE_CMR 7 | ||
100 | #define ASAP_TYPE_CMS 8 | ||
101 | #define ASAP_TYPE_DLT 9 | ||
102 | #define ASAP_TYPE_MPT 10 | ||
103 | #define ASAP_TYPE_RMT 11 | ||
104 | #define ASAP_TYPE_TMC 12 | ||
105 | #define ASAP_TYPE_TM2 13 | ||
106 | |||
107 | #define dGetByte(addr) UBYTE(ast _ memory[addr]) | ||
108 | #define dPutByte(addr, data) ast _ memory[addr] = CAST(byte) (data) | ||
88 | #define dGetWord(addr) (dGetByte(addr) + (dGetByte((addr) + 1) << 8)) | 109 | #define dGetWord(addr) (dGetByte(addr) + (dGetByte((addr) + 1) << 8)) |
89 | #define GetByte(addr) (((addr) & 0xf900) == 0xd000 ? ASAP_GetByte(ast, addr) : dGetByte(addr)) | 110 | #define GetByte(addr) (((addr) & 0xf900) == 0xd000 ? ASAP_GetByte(ast, addr) : dGetByte(addr)) |
90 | #define PutByte(addr, data) do { if (((addr) & 0xf900) == 0xd000) ASAP_PutByte(ast, addr, data); else dPutByte(addr, data); } while (FALSE) | 111 | #define PutByte(addr, data) do { if (((addr) & 0xf900) == 0xd000) ASAP_PutByte(ast, addr, data); else dPutByte(addr, data); } while (FALSE) |
91 | #define RMW_GetByte(dest, addr) do { if (((addr) >> 8) == 0xd2) { dest = ASAP_GetByte(ast, addr); AST cycle--; ASAP_PutByte(ast, addr, dest); AST cycle++; } else dest = dGetByte(addr); } while (FALSE) | 112 | #define RMW_GetByte(dest, addr) do { if (((addr) >> 8) == 0xd2) { dest = ASAP_GetByte(ast, addr); ast _ cycle--; ASAP_PutByte(ast, addr, dest); ast _ cycle++; } else dest = dGetByte(addr); } while (FALSE) |
113 | |||
114 | #define CYCLE_TO_SAMPLE(cycle) TO_INT(((cycle) * ASAP_SAMPLE_RATE + ast _ sample_offset) / ASAP_MAIN_CLOCK) | ||
92 | 115 | ||
93 | #endif /* _ASAP_INTERNAL_H_ */ | 116 | #endif /* _ASAP_INTERNAL_H_ */ |