Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //botscript parser - writeheader
- void BUFFER_WriteHeader( LONG lHeader )
- {
- LONG lSize;
- lSize = sizeof( LONG );
- if (( lSize + g_ulBufferSize ) >= DEFAULT_OBJECT_SIZE )
- ERROR_Error( "Object file size exceeds %d!\n", DEFAULT_OBJECT_SIZE );
- if ( lHeader >= NUM_DATAHEADERS )
- ERROR_Error( "Invalid header, %d!\n", lHeader );
- MAIN_DebugMessage( "%02d: %06d = %s\n", lSize, g_pBufferPtr - g_pBuffer, g_pszHeaders[lHeader] );
- // Copy the data to the current position in the object buffer.
- memcpy( g_pBufferPtr, (void *)&lHeader, lSize );
- // Move the buffer pointer and increased the object file size.
- g_ulBufferSize += lSize;
- g_pBufferPtr += lSize;
- }
- //acc parser - pc_appendcmd
- void PC_AppendCmd(pcd_t command)
- {
- if (ImportMode != IMPORT_Importing)
- {
- pc_LastAppendedCommand = command;
- if (pc_NoShrink)
- {
- MS_Message(MSG_DEBUG, "AC> %06d = #%d:%s\n", pc_Address,
- command, PCDNames[command]);
- command = MS_LittleUINT(command);
- Append(&command, sizeof(U_INT));
- }
- else
- {
- U_BYTE cmd;
- if (command != PCD_PUSHBYTE && PushByteAddr)
- { // Maybe shrink a PCD_PUSHBYTE sequence into PCD_PUSHBYTES
- int runlen = (pc_Address - PushByteAddr) / 2;
- int i;
- if (runlen > 5)
- {
- pc_Buffer[PushByteAddr] = PCD_PUSHBYTES;
- for (i = 0; i < runlen; i++)
- {
- pc_Buffer[PushByteAddr+i+2] = pc_Buffer[PushByteAddr+i*2+1];
- }
- pc_Buffer[PushByteAddr+1] = runlen;
- pc_Address = PushByteAddr + runlen + 2;
- pc_BufferPtr = pc_Buffer + pc_Address;
- MS_Message (MSG_DEBUG, "AC> Last %d PCD_PUSHBYTEs changed to #%d:PCD_PUSHBYTES\n",
- runlen, PCD_PUSHBYTES);
- }
- else if (runlen > 1)
- {
- pc_Buffer[PushByteAddr] = PCD_PUSH2BYTES + runlen - 2;
- for (i = 1; i < runlen; i++)
- {
- pc_Buffer[PushByteAddr+1+i] = pc_Buffer[PushByteAddr+1+i*2];
- }
- pc_Address = PushByteAddr + runlen + 1;
- pc_BufferPtr = pc_Buffer + pc_Address;
- MS_Message (MSG_DEBUG, "AC> Last %d PCD_PUSHBYTEs changed to #%d:PCD_PUSH%dBYTES\n",
- runlen, PCD_PUSH2BYTES+runlen-2, runlen);
- }
- PushByteAddr = 0;
- }
- else if (command == PCD_PUSHBYTE && PushByteAddr == 0)
- { // Remember the first PCD_PUSHBYTE, in case there are more
- PushByteAddr = pc_Address;
- }
- MS_Message(MSG_DEBUG, "AC> %06d = #%d:%s\n", pc_Address,
- command, PCDNames[command]);
- if (command < 256-16)
- {
- cmd = command;
- Append(&cmd, sizeof(U_BYTE));
- }
- else
- {
- // Room for expansion: The top 16 pcodes in the [0,255]
- // range select a set of pcodes, and the next byte is
- // the pcode in that set.
- cmd = ((command - (256-16)) >> 8) + (256-16);
- Append(&cmd, sizeof(U_BYTE));
- cmd = (command - (256-16)) & 255;
- Append(&cmd, sizeof(U_BYTE));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement