Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import "std.zh"
- const int SFX_KEYPRESS = 58;
- const int LINKTILEOFFSET = -261; const int KEY_DELAY = 7; //Trying this as 6.5 and timer changes as 1.0, using 65 and 10
- const int LINE_LENGTH = 54; const int BUFFER_LENGTH = 55;
- //int b1[55]; int b2[55]; int b3[55]; int b4[55]; int b5[55];
- //int b6[55]; int b7[55]; int b8[55]; int b9[55]; int b10[55];
- //int bufptr;
- const int CHAR_WIDTH = 4;
- const int CURSOR_WIDTH = 4;
- const int CURSOR_POINT_CHAR = 62;
- const int CURSOR_Y_OFFSET = 4;
- const int CURSOR_X_OFFSET = 4;
- const int BUFFER_OUTPUT_X = 0;
- const int BUFFER_OUTPUT_Y = 0;
- const int CURSOR_BLINK_DUR = 70;
- const int CURSOR_Y_OFS = 1;
- const int TAB_WIDTH = 4; //number of spaces in a tab keypress.
- //! The actual 'CHAR_TAB' shors as '^' in some fonts, hence doing it this way.
- int ram[64]; const int RAM_q = 0; const int RAM_lastchar = 1; const int RAM_cursorspacing = 2; const int RAM_cursorposition = 3;
- int buffer[214747]; //={CURSOR_POINT_CHAR, CHAR_SPACE};
- int bufferoverlay[214747]; //handles the cursor.
- bool ShiftKey;
- //int curbuffer = 0;
- int q; int timer = KEY_DELAY; bool cantype = true;
- int temp_q; int cursorblink = 0;
- //CursorAdv(RAM_q);
- void CursorAdv(int n){
- bufferoverlay[ram[n]] = CHAR_SPACE;
- ram[n]++;
- //bufferoverlay[ram[n]] = '_'; //Cursor.
- ram[RAM_cursorposition] += ram[RAM_cursorspacing];
- }
- //CursorRev(RAM_q);
- void CursorRev(int n){
- bufferoverlay[ram[n]] = 0;
- ram[n]--;
- if ( ram[RAM_cursorposition] >= ram[RAM_cursorspacing] ) ram[RAM_cursorposition] -= ram[RAM_cursorspacing];
- if ( ram[RAM_cursorposition] < 0 ) ram[RAM_cursorposition] = 0;
- //bufferoverlay[ram[n]] = '_'; //Cursor.
- }
- void ResetCursor(){
- //bufferoverlay[ram[]] = 0;
- ram[RAM_q] = 0;
- ram[RAM_cursorposition] = 0;
- ram[RAM_cursorspacing] = 0;
- }
- global script a{
- void run(){
- //int buffers[]={b1, b2, b3, b4, b5, b6, b7, b8, b9, b10};
- //bufptr = buffers;
- //int curbuffer = bufptr[ram[RAM_q]];
- Link->Y = 90;
- //Game->Cheat = 4;
- while(true){
- //Link->PressMap = false;
- Link->InputMap = false;
- if ( timer ) cantype = false;
- if ( !timer ) cantype = true;
- if ( Game->KeyPress[115] || Game->KeyPress[116] ) ShiftKey = true;
- else ShiftKey = false;
- if ( timer > 0 ) timer --;
- if ( timer <= 0 ) timer = 0;
- if ( cursorblink > 0 ) cursorblink--;
- if ( cursorblink <= 0 ) cursorblink = 100;
- if ( cantype ) {
- //NoAction(); //Link->PressMap = false; Link->InputMap = false;
- for ( int qq = 1; qq <= 26; qq++ ) {
- if ( Game->KeyPress[qq] ){
- NoAction();
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- {
- buffer[ram[RAM_q]] = CHAR_A-1+qq; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- break;
- }
- else {
- buffer[ram[RAM_q]] = CHAR_a-1+qq; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- break;
- }
- }
- }
- }
- if ( Game->KeyPress[27] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = ')'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '0'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[28] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '!'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '1'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[29] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '"'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '2'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[30] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '#'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '3'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[31] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '$'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '4'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[32] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '%'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '5'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[33] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '^'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '6'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[34] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '&'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '7'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[35] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '*'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '8'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[36] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '('; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '9'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[37] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '0'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[38] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '1'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[39] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '2'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[40] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '3'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[41] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '4'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[42] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '5'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[43] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '6'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[44] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '7'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[45] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '8'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[46] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '9'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[60] ){ //tilde -- this might have issues unless we can set uncap false.
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '~'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[61] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '_'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '-'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[62] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '+'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '='; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[63] ){ //backspace key
- //Do not permit backspace is we reach the first character of the buffer!
- if ( ram[RAM_q] < 214746 && ram[RAM_q] > 0 ) {
- CursorRev(RAM_q); temp_q--; buffer[ram[RAM_q]] = 0; //clear the last character typed.
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[64] ){ //tab
- if ( ram[RAM_q] < 214746 ) {
- for ( int w = 0; w < TAB_WIDTH; w++ ) { buffer[ram[RAM_q]] = CHAR_SPACE; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[65] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '{'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '['; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[66] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '}'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = ']'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[68] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = ':'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = ';'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[69] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = CHAR_DQUOTE; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = CHAR_QUOTE; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[70] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '|'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = CHAR_BSLASH; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[71] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '|'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = CHAR_BSLASH; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[72] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '<'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = ','; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[73] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '>'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '.'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[74] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '?'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '/'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[75] ){
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = CHAR_SPACE; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[77] ){ //delete
- if ( ram[RAM_q] < 214746 ) {
- for ( int w = ram[RAM_q]; w >= 0; w-- ) buffer[w] = 0;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- ResetCursor(); temp_q = 0;
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[78] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '~'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = '`'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[82] ){ //leftarrow
- Link->PressLeft = false; Link->InputLeft = false;
- if ( ram[RAM_q] < 214746 ) {
- //ram[RAM_q]--;
- CursorRev(RAM_q);
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);//temp_q--;
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[83] ){ //leftarrow
- Link->PressRight = false; Link->InputRight = false;
- if ( ram[RAM_q] < 214746 ) {
- CursorAdv(RAM_q);
- //ram[RAM_q]++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);//temp_q--; //needs to operate on temp_q so that the highest position is recorded.
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[84] ){ //up
- Link->PressUp = false; Link->InputUp = false;
- //find the previous command in the list
- /* if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '|'; q++; temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = CHAR_BSLASH; q++; temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- */
- }
- if ( Game->KeyPress[85] ){ //up
- Link->PressDown = false; Link->InputDown = false;
- //find the next command in the list, clear if none
- /* if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = '|'; q++; temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = CHAR_BSLASH; q++; temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- */
- }
- if ( Game->KeyPress[86] ){
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '/'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[87] ){
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '*'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[88] ){
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '-'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[89] ){
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '+'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[90] ){ //delete key, num pad
- if ( ram[RAM_q] < 214746 ) {
- buffer[ram[RAM_q]] = '/'; CursorAdv(RAM_q); temp_q++;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[91] ){
- if ( ram[RAM_q] < 214746 ) {
- for ( int w = q; w >= 0; w-- ) buffer[w] = 0;
- if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);
- q = 0; temp_q = 0;
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[101] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = ':'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = ';'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- if ( Game->KeyPress[105] ){
- if ( ram[RAM_q] < 214746 ) {
- if ( (Game->KeyPress[115] || Game->KeyPress[116]))
- { buffer[ram[RAM_q]] = ':'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- else { buffer[ram[RAM_q]] = ';'; CursorAdv(RAM_q); temp_q++; if ( SFX_KEYPRESS > 0 ) Game->PlaySound(SFX_KEYPRESS);}
- timer = KEY_DELAY;
- }
- }
- //for ( int qqq = 0; qqram[RAM_q] < SizeOfArray(bufferoverlay); qqq++ ) bufferoverlay[ram[RAM_q]] = CHAR_SPACE;
- //bufferoverlay[ram[RAM_q]] = '_'; //Cursor.
- }
- //Adjust the cursor position based on the size of the last typed character.
- if ( ram[RAM_q] > 0 ) {
- ram[RAM_lastchar] = buffer[ram[RAM_q]-1];
- ram[RAM_cursorspacing] = GetCursorSpacing(ram[RAM_lastchar]);
- }
- //If we backspace all the way, rfeser the cursor position to 0 in all respects.
- if ( ram[RAM_q] == 0 ) {
- ram[RAM_lastchar] = 0;
- ram[RAM_cursorspacing] = 0;
- }
- if ( timer == KEY_DELAY ) {
- Trace(ram[RAM_lastchar]);
- Trace(GetCursorSpacing(ram[RAM_lastchar]));
- Trace(ram[RAM_cursorspacing]);
- Trace(ram[RAM_cursorposition]);
- }
- Screen->DrawString(6,0,0,2, 0x01, -1, 0, GetBuffer(),128);
- if ( cursorblink > CURSOR_BLINK_DUR ) {
- int cursor[] = "_";
- Screen->DrawString(6,ram[RAM_cursorposition]+ram[RAM_cursorspacing],0+CURSOR_Y_OFS,2, 0x01, -1, 0, cursor,128); //cursor
- //Screen->DrawString(6,0,0+CURSOR_Y_OFS,2, 0x01, -1, 0, GetCursorOverlay(),128); //cursor
- /*
- Screen->Line(6,
- 0+0+(q*CHAR_WIDTH),
- //BUFFER_OUTPUT_X+CURSOR_X_OFFSET+(q*CHAR_WIDTH),
- //BUFFER_OUTPUT_Y+CURSOR_Y_OFFSET,
- 6,
- 0+0+(q*CHAR_WIDTH)+4,
- //BUFFER_OUTPUT_X+CURSOR_X_OFFSET+(q*CHAR_WIDTH) + CURSOR_WIDTH,
- 6,
- //BUFFER_OUTPUT_Y+CURSOR_Y_OFFSET,
- 0x01, 1, 0, 0, 0, 128);
- */
- }
- Waitdraw(); Waitframe();
- }
- }
- }
- int GetCursorSpacing(int chr, int font){
- if ( font == 0 ) {
- int spacing[]={
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, //tab
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //(29)
- 0, 0, // (31)
- 4, 2, 4, 6, 6, 4, 5, 2, 3, 3,
- 4, 4, 3, 4, 2, 0, 4, 3, 4, 4, //literal 3
- 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, //equals
- 4, 4, 5, //@ sign
- //A
- 5, 5, 4, 5, 4, 4, 5, 4, 2, 4,
- //K
- 5, 4, 6, 6, 5, 5, 5, 5, 5, 4,
- //U
- 5, 6, 6, 6, 4, 4, //Z
- //lbrace
- 4, 5, 4, 4, 4, 4,
- //a
- 5, 5, 4, 5, 4, 4, 5, 4, 2, 4,
- //k
- 5, 4, 6, 6, 5, 5, 5, 5, 5, 4,
- //u
- 5, 6, 6, 4, 4, 4, //z
- //{
- 4, 2, 4, 5,
- //127
- 0,
- //Forward Del
- 0
- };
- return spacing[chr];
- }
- }
- int GetCursorSpacing(int chr){
- //Custom kerning... Organised by English-language, and C-Programming linguistic frequency for short-circuiting,
- if ( chr == ' ' ) return 4;
- if ( chr == 'E' ) return 4; if ( chr == 'T' ) return 4; if ( chr == 'A' ) return 5; if ( chr == 'O' ) return 5; if ( chr == 'I' ) return 2;
- if ( chr == 'N' ) return 6; if ( chr == 'S' ) return 5; if ( chr == 'H' ) return 4; if ( chr == 'R' ) return 5; if ( chr == 'D' ) return 5;
- if ( chr == 'L' ) return 4; if ( chr == 'C' ) return 4; if ( chr == 'U' ) return 5; if ( chr == 'M' ) return 6; if ( chr == 'W' ) return 6;
- if ( chr == 'F' ) return 4; if ( chr == 'G' ) return 5; if ( chr == 'Y' ) return 4; if ( chr == 'P' ) return 5; if ( chr == 'B' ) return 5;
- if ( chr == 'V' ) return 6; if ( chr == 'K' ) return 5; if ( chr == 'J' ) return 4; if ( chr == 'X' ) return 6; if ( chr == 'Q' ) return 5;
- if ( chr == 'Z' ) return 4;
- if ( chr == 'e' ) return 4; if ( chr == 't' ) return 4; if ( chr == 'a' ) return 5; if ( chr == 'o' ) return 5; if ( chr == 'i' ) return 2;
- if ( chr == 'n' ) return 6; if ( chr == 's' ) return 5; if ( chr == 'h' ) return 4; if ( chr == 'r' ) return 5; if ( chr == 'd' ) return 5;
- if ( chr == 'l' ) return 4; if ( chr == 'c' ) return 4; if ( chr == 'u' ) return 5; if ( chr == 'm' ) return 6; if ( chr == 'w' ) return 6;
- if ( chr == 'f' ) return 4; if ( chr == 'g' ) return 5; if ( chr == 'y' ) return 4; if ( chr == 'p' ) return 5; if ( chr == 'b' ) return 5;
- if ( chr == 'v' ) return 6; if ( chr == 'k' ) return 5; if ( chr == 'j' ) return 4; if ( chr == 'x' ) return 4; if ( chr == 'q' ) return 5;
- if ( chr == 'z' ) return 4;
- if ( chr == '.' ) return 2; if ( chr == '!' ) return 2; if ( chr == ',' ) return 3; if ( chr == '?' ) return 4; if ( chr == ':' ) return 2;
- if ( chr == '1' ) return 3; if ( chr == '2' ) return 4; if ( chr == '3' ) return 4; if ( chr == '4' ) return 4; if ( chr == '5' ) return 4;
- if ( chr == '6' ) return 4; if ( chr == '7' ) return 4; if ( chr == '8' ) return 4; if ( chr == '9' ) return 4; if ( chr == '0' ) return 4;
- if ( chr == ';' ) return 2; f ( chr == '(' ) return 3; if ( chr == ')' ) return 3; if ( chr == '-' ) return 4;
- if ( chr == CHAR_QUOTE ) return 2; //Zeelda to be a parser bug. Comparing the buffer character ' ' ' to 'A' returned 5.
- if ( chr == CHAR_DQUOTE ) return 4;
- if ( chr == '{' ) return 4; if ( chr == '}' ) return 4; if ( chr == '&' ) return 5; if ( chr == '|' ) return 2; if ( chr == '_' ) return 4;
- if ( chr == '=' ) return 4; if ( chr == '*' ) return 4; if ( chr == '+' ) return 4; if ( chr == '/' ) return 4; if ( chr == '%' ) return 4;
- if ( chr == '<' ) return 4; if ( chr == '>' ) return 4; if ( chr == '[' ) return 4; if ( chr == ']' ) return 4; if ( chr == '~' ) return 5;
- if ( chr == '@' ) return 5; if ( chr == '#' ) return 6; if ( chr == '$' ) return 6; if ( chr == CHAR_POUNDS ) return 5; if ( chr == '^' ) return 4;
- if ( chr == CHAR_BSLASH ) return 5; if ( chr == '`' ) return 4;
- }
- int GetBuffer(){
- //int ptr = bufptr;
- //return bufptr[buffer];
- return buffer;
- }
- int GetCursorOverlay(){
- return bufferoverlay;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement